<legend id='40oK9'><style id='40oK9'><dir id='40oK9'><q id='40oK9'></q></dir></style></legend>
  • <tfoot id='40oK9'></tfoot>
      <i id='40oK9'><tr id='40oK9'><dt id='40oK9'><q id='40oK9'><span id='40oK9'><b id='40oK9'><form id='40oK9'><ins id='40oK9'></ins><ul id='40oK9'></ul><sub id='40oK9'></sub></form><legend id='40oK9'></legend><bdo id='40oK9'><pre id='40oK9'><center id='40oK9'></center></pre></bdo></b><th id='40oK9'></th></span></q></dt></tr></i><div id='40oK9'><tfoot id='40oK9'></tfoot><dl id='40oK9'><fieldset id='40oK9'></fieldset></dl></div>
    1. <small id='40oK9'></small><noframes id='40oK9'>

      • <bdo id='40oK9'></bdo><ul id='40oK9'></ul>

        可怕的“警告:imagecreatefromjpeg() : '/tmp/filename' 不是第 x

        the dreaded quot;Warning: imagecreatefromjpeg() : #39;/tmp/filename#39; is not a valid JPEG file in /phpfile.php on line xxxquot;(可怕的“警告:imagecreatefromjpeg() : /tmp/filename 不是第 xxx 行/phpfile.php 中的有效 JPEG 文件) - IT屋-程序员
          • <tfoot id='dYEaP'></tfoot>
            1. <small id='dYEaP'></small><noframes id='dYEaP'>

              <legend id='dYEaP'><style id='dYEaP'><dir id='dYEaP'><q id='dYEaP'></q></dir></style></legend>

                <tbody id='dYEaP'></tbody>
                <bdo id='dYEaP'></bdo><ul id='dYEaP'></ul>

                <i id='dYEaP'><tr id='dYEaP'><dt id='dYEaP'><q id='dYEaP'><span id='dYEaP'><b id='dYEaP'><form id='dYEaP'><ins id='dYEaP'></ins><ul id='dYEaP'></ul><sub id='dYEaP'></sub></form><legend id='dYEaP'></legend><bdo id='dYEaP'><pre id='dYEaP'><center id='dYEaP'></center></pre></bdo></b><th id='dYEaP'></th></span></q></dt></tr></i><div id='dYEaP'><tfoot id='dYEaP'></tfoot><dl id='dYEaP'><fieldset id='dYEaP'></fieldset></dl></div>

                  本文介绍了可怕的“警告:imagecreatefromjpeg() : '/tmp/filename' 不是第 xxx 行/phpfile.php 中的有效 JPEG 文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当有人将图片上传到我们的网站时,我收到了这个警告:

                  I've been getting this warning when some people upload images to our site :

                  警告:imagecreatefromjpeg()[function.imagecreatefromjpeg]:gd-jpeg:JPEG 库报告不可恢复的错误:在/home/pathremoved/includes/snapsutils.php第220行

                  Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/pathremoved/includes/snapsutils.php on line 220

                  警告:imagecreatefromjpeg()[function.imagecreatefromjpeg]:'/tmp/phpiw4MFk' 不是有效的 JPEG/home/pathremoved.php 中的文件在线220

                  Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/tmp/phpiw4MFk' is not a valid JPEG file in /home/pathremoved.php on line 220

                  警告:imagesx():提供的参数不是有效的图像资源/home/pathremoved.php 第 222 行

                  Warning: imagesx(): supplied argument is not a valid Image resource in /home/pathremoved.php on line 222

                  警告:imagesy():提供的参数不是有效的图像资源/home/pathremoved.php 第 223 行

                  Warning: imagesy(): supplied argument is not a valid Image resource in /home/pathremoved.php on line 223

                  警告:imagecreatetruecolor()[function.imagecreatetruecolor]:图像尺寸无效/home/pathremoved.php 第 240 行

                  Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/pathremoved.php on line 240

                  警告:imagecopyresampled():提供的参数不是有效的图像/home/pathremoved.php 中的资源第 242 行

                  Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/pathremoved.php on line 242

                  这仅发生在某些图像上,当在任何程序中打开时都可以,它甚至可以毫无问题地上传到我在 localhost 上的网站版本...我用谷歌搜索了一下,但没有发现任何结论...

                  This only happens with certain images, which when opened in any program are ok, it even uploads to the version of the site I have on localhost with no problems...I googled a bit but found nothing conclusive...

                  注意 php upload_max 大小为 5M,post_max_size 为 5M.这不是上传或内存问题.我已经用 400 万张图片进行了测试,没有任何问题.

                  note php upload_max size is 5M and post_max_size is 5M. This is not an upload or memory issue. I've tested with 4M images without problems.

                  任何帮助表示赞赏.

                  推荐答案

                  在 Google 上搜索了一下后,我发现 此错误报告.似乎 GD 库对有缺陷的 JPEG 文件的容忍度低于其他程序.建议的解决方案是在处理图像之前将 GD 设置为忽略 JPEG 错误,如下所示:

                  After a little digging around on Google I found this bug report. It seems that the GD library is less tolerant of buggy JPEG files than other programs. The solution suggested was to set GD to ignore JPEG error's before processing the image, like this:

                  ini_set("gd.jpeg_ignore_warning", 1);
                  

                  希望这对你有用.您可能遇到的另一个潜在问题与内存有关.似乎 GD 将所有图像在打开后作为位图保存在内存中.这意味着 5MB 的图像实际上可以消耗比单个 PHP 线程所允许的更多的内存,从而导致致命错误.我在上传一些图片时遇到了这个问题,为了解决这个问题,我不得不减小允许的最大文件大小.

                  Hopefully that will work for you. One other potential problem you may run into is to do with memory. It seems that GD holds all images in memory as bitmaps once they've been opened. This means that a 5MB image can actually consume more memory than a single PHP thread is allowed, resulting in a fatal error. I had this problem with some image uploads and had to reduce the maximum file size I allowed to get around the problem.

                  祝你好运,希望对你有所帮助.

                  Good luck and hope that helps.

                  这篇关于可怕的“警告:imagecreatefromjpeg() : '/tmp/filename' 不是第 xxx 行/phpfile.php 中的有效 JPEG 文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)

                    <small id='Bgqr5'></small><noframes id='Bgqr5'>

                      <bdo id='Bgqr5'></bdo><ul id='Bgqr5'></ul>
                      • <tfoot id='Bgqr5'></tfoot>
                        <i id='Bgqr5'><tr id='Bgqr5'><dt id='Bgqr5'><q id='Bgqr5'><span id='Bgqr5'><b id='Bgqr5'><form id='Bgqr5'><ins id='Bgqr5'></ins><ul id='Bgqr5'></ul><sub id='Bgqr5'></sub></form><legend id='Bgqr5'></legend><bdo id='Bgqr5'><pre id='Bgqr5'><center id='Bgqr5'></center></pre></bdo></b><th id='Bgqr5'></th></span></q></dt></tr></i><div id='Bgqr5'><tfoot id='Bgqr5'></tfoot><dl id='Bgqr5'><fieldset id='Bgqr5'></fieldset></dl></div>
                          <tbody id='Bgqr5'></tbody>
                          <legend id='Bgqr5'><style id='Bgqr5'><dir id='Bgqr5'><q id='Bgqr5'></q></dir></style></legend>