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.

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

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向