alhena Posted June 11, 2011 Share Posted June 11, 2011 Hi all, I have a script that creates an image and saves it to a file. Until recently, I had PHP 5.2.11 on the server, yesterday it got upgraded to 5.3.3 ("-7+squeeze1" to be exact, no idea what that means). Ever since, the images refuse to be saved. I can create the image just fine, even display in the browser (when header is set to image). I'm not getting any error messages, which may or may not have to do with the error reporting settings in the server configuration (I don't have access to that or the error logs). error_reporting ( E_ALL ) doesn't make a difference. // this is not working imagejpeg($image, "testing.jpg"); // this is working fine imagejpeg($image); I'm wondering if this has to do with safe_mode being enabled in the new PHP version. To be precise, it says "on" for Local Value and "off" for Master Value. They were both set to "off" in the old configuration. I did make sure to chmod the directory where the image is supposed to be saved to to 777, but it made no difference. Do I need to email the tech guys to turn safe_mode off? Or is the problem somewhere else? Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/ Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 It looks like this function is restricted when used in safe mode. There is a person who talks about this issue and has seemed to find a solution here. http://us2.php.net/manual/en/function.imagejpeg.php Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228385 Share on other sites More sharing options...
alhena Posted June 11, 2011 Author Share Posted June 11, 2011 Which one do you mean? There are several that mention problems with safe_mode. I tried both "touch" and "ini_set", and neither works. The third mentions something about moving an uploaded file, which is not what I have. Is there any other way to get around safe_mode, or is it simply impossible to save an image to file in safe_mode? Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228418 Share on other sites More sharing options...
PFMaBiSmAd Posted June 11, 2011 Share Posted June 11, 2011 You need to first find out why the function is failing. Use both of the following lines to set the error_reporting/display_errors settings (assuming your host has not disabled ini_set or the error_reporting statements) - ini_set("display_errors", "1"); error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228523 Share on other sites More sharing options...
alhena Posted June 12, 2011 Author Share Posted June 12, 2011 Thanks. This is interesting... error_reporting ( E_ALL ) did not show any errors, but this made them show up. Warning: imagejpeg(): SAFE MODE Restriction in effect. The script whose uid is 10000 is not allowed to access [directory link] owned by uid 33 in [script link] on line 40 Warning: imagejpeg(): Invalid filename in [script link] on line 40 So safe mode really is to blame, it seems. The directory mentioned in the warning does have 777 rights, so it's a bit odd why it would still be restricted. Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228728 Share on other sites More sharing options...
PFMaBiSmAd Posted June 12, 2011 Share Posted June 12, 2011 This feature has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. ^^^ Given that safe mode is depreciated and soon to be removed from php, I'm wondering why your host has turned it on, assuming they know that they have turned it on. Safe mode doesn't check the file/folder permission settings, it checks the user id of the file/folder owner and that of the currently running script. Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228736 Share on other sites More sharing options...
alhena Posted June 12, 2011 Author Share Posted June 12, 2011 I'm wondering the same, especially since safe mode was off in the old PHP installation. Maybe it was an oversight, or it's set to on by default and has to be adjusted manually. Is there any way I can change the user id of the folder and the script so they match? Or is this out of my hands? Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228738 Share on other sites More sharing options...
jcbones Posted June 12, 2011 Share Posted June 12, 2011 Contact your host, and ask them to turn it off! Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228739 Share on other sites More sharing options...
xyph Posted June 12, 2011 Share Posted June 12, 2011 Use PHP to create any folders you want PHP to access... Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228743 Share on other sites More sharing options...
alhena Posted June 12, 2011 Author Share Posted June 12, 2011 Use PHP to create any folders you want PHP to access... I did. It made no difference. I guess that means I'll have to wait for them to turn safe_mode off. Thanks to everyone who replied! Quote Link to comment https://forums.phpfreaks.com/topic/239068-imagejpeg-problem-saving-to-file/#findComment-1228762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.