警告:filesize():img.jpg的统计信息失败 [英] Warning: filesize(): stat failed for img.jpg

查看:98
本文介绍了警告:filesize():img.jpg的统计信息失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取图像的文件大小,并且不断获取Warning: filesize(): stat failed for img.jpg

I am trying to get the file size of an image and I keep getting Warning: filesize(): stat failed for img.jpg

这就是我所做的:

$path = $_FILES['profile']['name'];
$path = iconv('UTF-8', 'ISO-8859-1',$path);
if (!in_array(pathinfo($path,PATHINFO_EXTENSION),$allowed)) {
    return "file";
} elseif (filesize($path)>(1024*600))

我能够得到文件扩展名没问题,但是filesize()似乎不起作用.我已经阅读了一下,确实找到了,但是它没有解决问题.任何帮助深表感谢!

I am able to get the file extension no problem but the filesize() just doesn't seem to work. I have been reading a bit and did find this but it did not solve the problem. Any help is much appreciated!

推荐答案

['name']是CLIENT计算机上文件的名称.它仅是信息,与服务器上实际存储的内容完全无关.您需要查看['tmp_name'],这是上传完成后PHP将文件临时存储在服务器上的位置:

['name'] in the $_FILES array is the name of the file on the CLIENT machine. It is information only, and has absolutely no relevance to what's actually stored on your server. You need to look at ['tmp_name'], which is where PHP has stored the file temporarily on the server, after the upload completed:

$path = $_FILES['profile']['tmp_name'];
                          ^^^^^^^^^^^^

这篇关于警告:filesize():img.jpg的统计信息失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆