Jump to content

fopen() in safe mode??


mattachoo

Recommended Posts

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 99

Warning: 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 99
Cannot 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.
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.