Jump to content

Recommended Posts

Posted

Hello all, I've been reading all the upload problem posts and still can't determine how to fix my upload problem. Here is my php script:

 

>if (is_uploaded_file($temp_file_name)) {
		if (move_uploaded_file($temp_file_name, $upload_dir.$file_name)) {
			$log = $upload_log_dir.$y."_".$m."_".$d.".txt";					//Log File Name
			$fp = fopen($log,"a+");											//Set File Pointer
			fwrite($fp,"\n$ip | $file_name | $screen_size | $date | $time");	//Write File
			fclose($fp);													//Close File Pointer
			$_SESSION['result'] = "green";
			return TRUE;
		} else {
			$_SESSION['result'] = "brown";
			return FALSE;

 

The returns error that I get is:

 

"Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/upload/20.pdf) is not within the allowed path(s): (/home/******:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/*****/public_html/account/scripts/upload.php on line 202"

 

I've kinda picked up on the fact that I need to change some settings in htaccess?

 

Thanks so much guys - You're the best!

 

-Bennett

Posted

Hi Bennett,

 

Welcome to the forums :)

 

You are trying to upload to "/upload/20.pdf" which is not allowed. You neet to set it to upload to "/home/*****/public_html/upload/20.pdf" (or wherever you want to upload it to that is in your allocated space.

 

If you change the variable $upload_dir to include the full path, you should be fine.

Posted

Thanks a bunch!

 

I can upload the files now but when I try to write to the log file I get another error. Any ideas?

 

Warning: fopen(/home/******/public_html/upload/upload_logs/2006_09_28.txt) [function.fopen]: failed to open stream: Permission denied in /home/******/public_html/account/scripts/upload.php on line 204

 

Warning: fwrite(): supplied argument is not a valid stream resource in /home/******/public_html/account/scripts/upload.php on line 205

 

Warning: fclose(): supplied argument is not a valid stream resource in /home/******/public_html/account/scripts/upload.php on line 206

 

I set the permission of /upload/ to 777 but I still get the same thing. Do I need to do this to another folder/file or are fwrite and fclose allowed?

 

Thanks again,

 

Bennett

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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