简体   繁体   English

tmp_name的PHP文件上传问题

[英]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.

相关问题 PHP 文件上传错误 tmp_name 为空 - PHP file upload error tmp_name is empty PHP codeigniter 文件上传 $_FILES['pic']['tmp_name']; - PHP codeigniter file upload $_FILES['pic']['tmp_name']; 有没有办法通过 PHP 上传带有特定“tmp_name”的文件? - Is there a way to upload a file through PHP with specific “tmp_name”? 在Linux中使用php上传,tmp_name为空 - Upload with php in Linux, the tmp_name is empty PHP文件上载错误(UPLOAD_ERR_PARTIAL)/ $ _FILES为空或具有空“tmp_name” - PHP file upload error (UPLOAD_ERR_PARTIAL) / $_FILES is null or has empty“tmp_name” _FILES['file1']['tmp_name'] 尝试在 php 中上传文件时为空 - _FILES['file1']['tmp_name'] is empty when tried to upload file in php PHP和Ajax文件上传-无法通过$ _FILES获得tmp_name - PHP and Ajax file upload - Can't get the tmp_name with $_FILES 角度图像上传到PHP服务器tmp_name丢失 - Angular image upload to PHP server tmp_name missing 使用AJAX发送的PHP中的App引擎将$ _FILES [“ file”] [“ tmp_name”]上传到Cloud Storage - Upload $_FILES[“file”][“tmp_name”] to Cloud Storage with App engine in PHP sent from AJAX 使用iOS Safari的PHP图片上传未提供TMP_NAME - PHP Image upload with iOS Safari not providing TMP_NAME
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM