mattachoo Posted October 27, 2006 Share Posted October 27, 2006 In a form, I want to be able to upload a picture from my computer, then using php, automatically resize the picture, then save it to a folder. I figured out how to do all that on my server, then when I tested it on my clients website, I get this error when I submit the form. [code]Warning: fopen(): SAFE MODE Restriction in effect. The script whose uid is 506 is not allowed to access / owned by uid 0 in /home/virtual/site3/fst/var/www/html/snapshot.class.php on line 99Warning: fopen(/images/band_pics/TOP.jpg): failed to open stream: No such file or directory in /home/virtual/site3/fst/var/www/html/snapshot.class.php on line 99Cannot open file (/images/band_pics/TOP.jpg)[/code]Is there a way I can turn of this mysterious SAFE MODE. The folder /images/band_pics/ is chmod 777, I think, so I don't think it is becuase of that. If someone can help me on this one I would be VERY thankful. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 27, 2006 Share Posted October 27, 2006 looking at you error it's were you put the script.please post your code cheers. Quote Link to comment Share on other sites More sharing options...
mattachoo Posted October 28, 2006 Author Share Posted October 28, 2006 Well, The script is simply in the root directory. Here is the phpinfo, if that helps. [table][tr][td]Directive[/td][td]Local Value[/td][td]Master Value[/td][/tr][tr][td]safe_mode[/td][td]On[/td][td]Off[/td][/tr][tr][td]safe_mode_exec_dir[/td][td]no value[/td][td]no value[/td][/tr][tr][td]safe_mode_gid[/td][td]Off[/td][td]Off[/td][/tr][tr][td]safe_mode_include_dir[/td][td]no value[/td][td]no value[/td][/tr][/table]I am using a class called 'ImageSnapshot' (snapshot.class.php), and the part in the class that uses fopen() is as follows: [code]<?function SaveImageAs($destination) { //Saves the image to the desination. Returns true if successful, or false with Err specifying the error. //example: $myimage->SaveImageAs("/docroot/images/newimage.jpg if ($this->ProcessImage()) { if (!$handle = fopen($destination, 'w')) { $this->Err = 'Cannot open file (' . $destination . ')'; return false; } else { if (fwrite($handle, $this->InternalImage) === FALSE) { $this->Err = 'Cannot write to file (' . $destination . ')'; return false; } else { return true; } fclose($handle); } } else { return false; }}?>[/code]ProcessImage() does the storing part of the image here:[code]<?imagecopyresampled($new_photo, $tmp_image,0,0,$source_x,$source_y, $this->Width, $this->Height, $this->Width, $this->Height);ob_start(); imagejpeg($new_photo,null,$this->Compression); $this->InternalImage = ob_get_contents();ob_end_clean();?>[/code]It stores the image in $this->InternalImage.If you need anything else, ask. Otherwise if anyone knows why it won't let me do this, PLEASE LET ME KNOW! Thanks! Quote Link to comment Share on other sites More sharing options...
mattachoo Posted November 3, 2006 Author Share Posted November 3, 2006 If anyone knows, I would still appreciate it. Thanks Quote Link to comment Share on other sites More sharing options...
Orio Posted November 3, 2006 Share Posted November 3, 2006 Try adding in the beging:ini_set("safe_mode",0);Orio. Quote Link to comment 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.