[英]PHP file upload issue with tmp_name
Issue with uploading some Images. 上传一些图片时出现问题。 I was trying to store image in mysql blob type. 我试图以mysql blob类型存储图像。 It was successful for some images but for some other images, it results in error. 对于某些图像,此操作成功,但对于某些其他图像,则导致错误。
warning in logs are as below: 日志中的警告如下:
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 file code: 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')";
but for some other images, it results in error 但对于其他一些图像,则会导致错误
This is the point.... Maybe you should add a var_dump($_FILES['userfile']) to check the property of those error images. 这就是重点....也许您应该添加一个var_dump($ _ FILES ['userfile'])来检查那些错误图像的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.