简体   繁体   English

GD-使用imagecreatefromstring()的无效PNG文件错误

[英]GD - Invalid PNG file error using imagecreatefromstring()

I am creating a site that allows users to upload an ZIP file of PNG, JPG, and GIF images and then manipulates them. 我正在创建一个站点,该站点允许用户上传PNG,JPG和GIF图像的ZIP文件,然后对其进行操作。 I first validate the headers to confirm that all of the files are one of the three. 我首先验证标题以确认所有文件都是这三个文件之一。 Then I use imagecreatefromstring() to convert the raw data into a GD image resource. 然后,我使用imagecreatefromstring()将原始数据转换为GD图像资源。 This works for most images I have uploaded. 这适用于我上传的大多数图像。 But on some PNG files I get an error saying that it isn't the proper format. 但是在某些PNG文件上,我收到一条错误消息,说它不是正确的格式。 I am unsure as to were this error is coming from. 我不确定这个错误是从哪里来的。

The server is running the latest PHP 5 and Apache2 on Ubuntu 10.10 Maverick 64-bit. 该服务器在Ubuntu 10.10 Maverick 64位上运行最新的PHP 5和Apache2。

Have you confirmed that these files are indeed in the proper format after you've unzipped them on the server? 在服务器上解压缩这些文件后,是否确认这些文件的格式确实正确? Also, what is the file size of these images? 另外,这些图像的文件大小是多少? The imagecreatefromstring() function can use quite a bit of memory; imagecreatefromstring()函数可能会占用大量内存。 maybe you're hitting a memory limit somewhere. 也许您正在某个地方达到内存限制。

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

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