简体   繁体   English

PHP的getimagesize停止工作

[英]php getimagesize stopped working

My script has been working fine until now; 到目前为止,我的脚本运行良好。 I was able to upload images files without any issues, but not recently. 我能够上传图像文件而没有任何问题,但是最近没有。 This is how I am troubleshooting the problem: 这是我对问题进行故障排除的方式:

Check if the file is uploaded or not. 检查文件是否上传。

if ($_FILES['foto']["error"] > 0){
    echo "Upload of photo image file failed (".$_FILES["foto"]["error"].").";
}

No error is returned, hence upload was successful. 没有错误返回,因此上传成功。

Next, I tried to echo out $_FILES['foto']['tmp_name'] , this too returns the path. 接下来,我尝试回显$_FILES['foto']['tmp_name'] ,这也返回了路径。

Next, I checked if the function exists: function_exists('getimagesize'); 接下来,我检查该函数是否存在:function_exists('getimagesize'); this returns true 这返回true

Next, I confirm the value of allow_url_fopen = On in php.ini 接下来,我在php.ini中确认allow_url_fopen = On的值

Finally, this line var_dump(getimagesize($_FILES['foto']['tmp_name'])); 最后,这一行var_dump(getimagesize($_FILES['foto']['tmp_name'])); returns bool(false) 返回布尔值(false)

What is happening here and why is getimagesize function failing. 这里发生了什么,为什么getimagesize函数失败。 I tried with different image types. 我尝试了不同的图像类型。

What if you move the image to a non-temp directory first and then execute getimagesize , eg: 如果先将图像移动到非临时目录然后执行getimagesize ,该怎么办,例如:

move_uploaded_file($_FILES['foto']['tmp_name'], '/my/dir/' . $_FILES['foto']['name']);
var_dump(getimagesize('/my/dir/' . $_FILES['foto']['name']));

This is a very strange issue; 这是一个非常奇怪的问题。 when I repeated the process using Chrome browser, there was NO ERROR at all. 当我使用Chrome浏览器重复该过程时,根本没有错误。 This problem occurs only with the most recent version of Microsoft's internet explorer 11. Apparently, the browser has some issues with uploading the user submitted content. 仅当使用最新版本的Microsoft Internet Explorer 11时才会出现此问题。显然,浏览器在上传用户提交的内容时存在一些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM