c_shelswell Posted July 24, 2008 Share Posted July 24, 2008 Hi I've got a script to resize images that a user uploads. This all works fine but I've come across a problem with it on another server. If the user uploads pictures over a certain pixel size i get a 500 internal server error which i've found is caused by php not having enough memory. Does anyone know of a way to get round this? Can I temporarily set the php memory from a script? I don't think i can use a htaccess file. Any ideas would be great. Cheers Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/ Share on other sites More sharing options...
JonnyThunder Posted July 24, 2008 Share Posted July 24, 2008 You can change the upload limit in PHP.INI. if you dont have access, ask your host. Sometimes they allow the use of a PHP.INI file in the directory where the script runs, to override the global default value. Or perhaps a bit of javascript which checks the filesize before submission. Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598533 Share on other sites More sharing options...
samshel Posted July 24, 2008 Share Posted July 24, 2008 try ini_set("memory_limit", "16MB"); although it is not advisable as your hosting company will not like this Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598535 Share on other sites More sharing options...
JonnyThunder Posted July 24, 2008 Share Posted July 24, 2008 I'd think the limit he's hitting will be to do with timeout for uploads, rather than memory. Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598537 Share on other sites More sharing options...
samshel Posted July 24, 2008 Share Posted July 24, 2008 agree JonnyThunder !! can be...in that case you are right Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598539 Share on other sites More sharing options...
JonnyThunder Posted July 24, 2008 Share Posted July 24, 2008 Im sitting on the fence, just in case! ;D Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598543 Share on other sites More sharing options...
c_shelswell Posted July 24, 2008 Author Share Posted July 24, 2008 Hi thanks for your replies. I've tried using set_time_limit(0) in the script doing the resizing, to no avail. It works on a different server where the memory is set to 24mb this server is 20mb. I don't have access to the .ini file unfortunately and the provider won't turn it up. I'm going to give this a go : "ini_set("memory_limit", "16MB");" cheers samshel. I take it I just add that at the top of my script? Cheers Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598544 Share on other sites More sharing options...
samshel Posted July 24, 2008 Share Posted July 24, 2008 yes add it at the top. try with different figures 32MB, 64 MB but higher figures would attract anger from your hosting company as i already said Link to comment https://forums.phpfreaks.com/topic/116397-image-resizing-with-not-enough-php-memory/#findComment-598587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.