上传部分图片时出现问题。我试图将图像存储在mysql blob类型中。它对某些图像是成功的,但对于其他一些图像,它会导致错误。
日志中的警告如下:
Warning: fopen(): Filename cannot be empty in C:\xampp\htdocs\KITSW zone\Modules\Timeline\Admin\image_post.php on line 32
Warning: fread() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\KITSW zone\Modules\Timeline\Admin\image_post.php on line 33
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\KITSW zone\Modules\Timeline\Admin\image_post.php on line 35
php文件代码:
$filename = $_FILES['userfile']['name'];
$tmpname = $_FILES['userfile']['tmp_name'];
$file_size = $_FILES['userfile']['size'];
$file_type = $_FILES['userfile']['type'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$fp = fopen($tmpname, 'r');
$content = fread($fp, filesize($tmpname));
$content = addslashes($content);
fclose($fp);
$final = "INSERT INTO `files`(`by_user`, `name`, `type`, `size`, `data`, `category`, `categoryid`)
VALUES('$by_user', '$filename','$file_type','$file_size','$content','timeline','$inserted')";
答案 0 :(得分:0)
但对于其他一些图像,则会导致错误
这是重点...... 也许你应该添加一个var_dump($ _ FILES ['userfile'])来检查这些错误图像的属性。