如何在php中将图像文件存储到数据库中? [英] How to store image file into database in php?

查看:56
本文介绍了如何在php中将图像文件存储到数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$src = imagecreatefromjpeg($folder.$filename);

$tmp = imagecreatetruecolor($targ_w, $targ_h);
imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
imagejpeg($tmp, $folder.'t_'.$filename,100);

imagedestroy($tmp);
imagedestroy($src);

如何将$src文件存入数据库

推荐答案

例如,使用 fopen(),使用 fread(),然后将该内容存储到,例如BLOB 数据库中的字段.

For example, open file using fopen(), read its content using fread(), and then store that content to, e.g. BLOB field in database.

将文件存储在 Dagon 评论中建议的文件系统上总是更好的解决方案.

It's always better solution to store file(s) on file system like Dagon suggested in comment.

这篇关于如何在php中将图像文件存储到数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆