Jump to content


Photo

fopen() in safe mode??


  • Please log in to reply
4 replies to this topic

#1 mattachoo

mattachoo
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 27 October 2006 - 04:43 AM

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. 
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)

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.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 27 October 2006 - 06:49 AM

looking at you error it's were you put the script.

please post your code cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 mattachoo

mattachoo
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 28 October 2006 - 06:21 PM

Well, The script is simply in the root directory.  Here is the phpinfo, if that helps. 






























Directive Local Value Master Value
safe_mode On Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value


I am using a class called 'ImageSnapshot' (snapshot.class.php), and the part in the class that uses fopen() is as follows:

<?
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;		
	}
}
?>

ProcessImage() does the storing part of the image here:
<?
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();
?>
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!

#4 mattachoo

mattachoo
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 03 November 2006 - 09:19 PM

If anyone knows, I would still appreciate it.  Thanks

#5 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 03 November 2006 - 09:37 PM

Try adding in the beging:
ini_set("safe_mode",0);

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users