douchengfei3985 2017-04-20 11:55
浏览 46
已采纳

php调整大小类失败,在dreamhost上使用更大的图像文件大小

This is an odd error I'm encountering and reaching out to see if anyone can help me pin down why this is happening.

So basically, I've got a form that uploads an image using jquery ajax, then uses a resizing class http://jarrodoberto.com/articles/2011/09/image-resizing-made-easy-with-php to crop the image. I've noticed with images over 1mb the script fails with no error messages. Also, this is only happening on dreamhost. On my host gatorserver everything works as it should.

What is odd to me is that images smaller in size seem to work fine. All of the php ini settings are well above the limits so I know that's not the issue and both servers are running php 5.6. and have error reporting on.

I've also tested this script directly without ajax and it does not work on images much over 1mb.

include('resize-class.php');
$resizeObj = new resize('photo.jpg');
$resizeObj -> resizeImage(250,250,'auto');
$resizeObj -> saveImage('photo-test.jpg', 100);

So this obviously is something with the script and how dreamhost is setup.

Any ideas why this is happening?

Upon further testing I'm finding this error Allowed memory size of 94371840 bytes exhausted this same test only produces this error on dreamhost and only certain jpg files, not on hostgator. So this has something to do with dreamhost and certain jpg files.

  • 写回答

1条回答 默认 最新

  • douyan9417 2017-04-21 11:01
    关注

    The solution was to modify the dreamhost phprc file located in /home/username/.php/5.6/phprc to something similar to the following

    upload_max_filesize = 100M
    post_max_size = 105M
    max_execution_time = 500
    max_input_time = 250
    memory_limit = 256M
    

    https://help.dreamhost.com/hc/en-us/articles/214894037-How-do-I-create-a-phprc-file-via-FTP-

    ONE IMPORTANT THING TO NOTE: The changed php settings take about 10 min to take effect as I'm supposing they are part of a cgi process that restarts ever so often.

    The memory limit seemed to be causing the error.

    Not sure why this resize-class.php script would need that much memory to resize a 1mb photo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部