怎么把上传了的图片改名啊 ? 还有怎么把图像转为二进制数据,储存在MYSQL数据库上了? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 rename(oldname,newname);把字段的数据类型设为mediumtext 你上传的时候COPY过来的时候重命名,字节fopen打开!就可以二进制读取了! <?php// 在 4.1.0 以前的 PHP 中,需要用 $HTTP_POST_FILES 代替 $_FILES。// 在 4.0.3 以前的 PHP 中,需要用 copy() 和 is_uploaded_file() 来代替 move_uploaded_file()。$uploaddir = '/var/www/uploads/';$uploadfile = $uploaddir. $_FILES['userfile']['name'];print "<pre>";if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) { print "File is valid, and was successfully uploaded. Here's some more debugging info:\n"; print_r($_FILES);} else { print "Possible file upload attack! Here's some debugging info:\n"; print_r($_FILES);}print "</pre>";?>bool move_uploaded_file ( string filename, string destination)本函数检查并确保由 filename 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 destination 指定的文件。 string destination 就是目标文件的完整路径和文件名例如 "../tmp/20040512.jpg"20040512 可以自己生成! 例如 "..tmp/".time().".jpg" <?$handle = fopen("image.jpg", "rb");$contents = fread ($handle, filesize ($filename));fclose ($handle);?> $contents就是图片的二进制字符串 ,直接写在数据库就可以了! cokeyang(西北狼) 现在我把二进制字符串直接写在数据库,可是读出来是乱码啊?要怎么读出来了? 读出来的时候要header 出文件的类型! header("Content-type: image/jpg");这样吗? 你有没有下载过PHP编程例啊你去找找,里面有你要的 怎样各个页面之间传递数值呢? php时间低于1970怎么处理 利用AJAX实现自动更新--用户触发 zend Freamework怎么访问不了 刚学,请问这就SQL哪里错了 如果将JAVASCRIPT中大规模的数据传入PHP 数据库中是转义字符,如果用php输出html效果 小问题 thinkPHP的模板 求PHP高手啊 apache安装问题 一位网友送的空间和域名,开了一个论坛,速度飞快。特此感谢。也为里面的PHP版做个广告。 不希望url上出现php?field=11之类的,有办法没?
mediumtext
// 在 4.1.0 以前的 PHP 中,需要用 $HTTP_POST_FILES 代替 $_FILES。
// 在 4.0.3 以前的 PHP 中,需要用 copy() 和 is_uploaded_file() 来代替 move_uploaded_file()。$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
?>bool move_uploaded_file ( string filename, string destination)本函数检查并确保由 filename 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 destination 指定的文件。
20040512 可以自己生成! 例如 "..tmp/".time().".jpg"
$handle = fopen("image.jpg", "rb");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
?>
$contents就是图片的二进制字符串 ,直接写在数据库就可以了!
header 出文件的类型!