douchengfei3985 2017-04-20 19: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 19: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.

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

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)