bwaxse Posted September 28, 2006 Posted September 28, 2006 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 Quote
TCH-Andy Posted September 28, 2006 Posted September 28, 2006 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. Quote
bwaxse Posted September 28, 2006 Author Posted September 28, 2006 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 Quote
TCH-Andy Posted September 28, 2006 Posted September 28, 2006 Have you changed the permissions to upload_logs ? Quote
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.