This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
在你提供更多信息之前,我真的帮不了什么忙。以下代码:(
其中 $file 等于问题中给出的图像的位置),输出:
这看起来没问题。我假设您的支票中其他地方有错误?
Until you give more information, I can't really help much. The following code:
(Where $file is equal to the location of the image given in the question), outputs:
This seems okay. I'm assuming an error somewhere else in your checks?
环顾四周后,我发现了这个关于PHP 的上传限制。我将它与我已经知道的内容结合起来,最后在我的 .htaccess 中使用以下代码使其正常工作(将上传限制为 5MB):
底线是:问题不在 PHP 的
getimagesize()
函数中,由于 Apache 和 PHP 中的文件大小限制,图像从未上传到服务器。感谢所有回答和评论的人,如果没有你们的帮助,弄清楚这个问题会更加痛苦!After looking around SO I've found this insightful answer regarding PHP's upload limits. I combined it with what I already knew and finally got it working using the following code in my .htaccess (limiting uploads to 5MB):
Bottom line is: the problem wasn't in PHP's
getimagesize()
function, it was that the images were never uploaded to the server due to file size limits in both Apache and PHP. Thanks everyone who answered and commented, It would have been a lot more painful to figure it out without your help!我不确定这是否是您正在寻找的答案,但我知道我对 php 函数和任何尺寸超过 3000px 的图像都有问题。
希望有帮助!
I am not sure if this is the answer your looking for but I know that I have issues with php functions and images being over 3000px in any dimension.
Hope that helps!
你说
您检查上传错误吗? - 当上传失败时,PHP 设置文件数组的
error
元素。有关不同错误,请参阅 PHP 文档的文件上传部分代码可能。You said
Did you check for an upload error? - When the upload fails PHP sets the
error
element of the file's array. See the PHP documentation's File Upload section for different error codes possible.我遇到了同样的问题,我使用了与 img 标签中使用的完全相同的文件引用:
当我删除文件名中的第一个斜杠并再次尝试时,它起作用了:
我希望它也适用于其他人。
I faced the same problem, i used exactly the same file reference as used in the img tag:
When I removed the first slash in the file name and tried it again, it worked:
I hope it works for others too.