smc Posted April 26, 2006 Share Posted April 26, 2006 Hi, first let me quickly introduce myself as SMC. I have looked around and hopefully found a good php support forum at last :)Alright lets jump right into it.I'm creating an upload script, eventually it will be just for images but as of now I just want to get it to work.I am using this code:[code]<?phpif($file_name !=""){copy ("$file", "/usr/local/apache_1.3.34/$file_name") or die("Could not copy file");}else { die("No file specified");}?><html><head><title>Project Cold Fusion Upload Centre :: Upload Complete</title></head><body><h3>File upload succeeded...</h3><ul><li>Sent: <?php echo "$file_name"; ?><li>Size: <?php echo "$file_size"; ?> bytes<li>Type: <?php echo "$file_type"; ?></ul><a href="<?php echo "$file_name" ?>">Click here to view your file</a></br><b>File Address:</b> http://www.smc.xeeblo.net/<?php echo "$file_name" ?></body></html>[/code]Now this is the error message I get when trying to upload:[code]Warning: copy(): open_basedir restriction in effect. File(/usr/local/apache_1.3.34/uploadgfx copy.jpg) is not within the allowed path(s): (/home/smc:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/smc/public_html/uploader.php on line 4Warning: copy(/usr/local/apache_1.3.34/uploadgfx copy.jpg): failed to open stream: Operation not permitted in /home/smc/public_html/uploader.php on line 4Could not copy file[/code]Now I'm using the correct apache version but I can't trace the error. ANY help would be greatly appreciated!Thank you very much,SMCPS: I did set the permissions for both files to 777 Quote Link to comment https://forums.phpfreaks.com/topic/8506-upload-form-difficulties/ Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 Hi,take a look in the apache config file, you should probably see a directive called open_basedir, here you can set which directories your scripts have access to. Also check the permissions on the folder where you want to write your files to, it should be writeable by the user under which apache runs. (the user under which apache runs can also be found in the apache config file).Koen. Quote Link to comment https://forums.phpfreaks.com/topic/8506-upload-form-difficulties/#findComment-31132 Share on other sites More sharing options...
DepretioN Posted April 26, 2006 Share Posted April 26, 2006 Make sure your upload_tmp_dir in your php.ini is set to the folder you are trying to upload that file to. Does the file upload anyway as this is just a warning? Quote Link to comment https://forums.phpfreaks.com/topic/8506-upload-form-difficulties/#findComment-31133 Share on other sites More sharing options...
smc Posted April 26, 2006 Author Share Posted April 26, 2006 [!--quoteo(post=369032:date=Apr 26 2006, 06:02 PM:name=Koen Calliauw)--][div class=\'quotetop\']QUOTE(Koen Calliauw @ Apr 26 2006, 06:02 PM) [snapback]369032[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,take a look in the apache config file, you should probably see a directive called open_basedir, here you can set which directories your scripts have access to. Also check the permissions on the folder where you want to write your files to, it should be writeable by the user under which apache runs. (the user under which apache runs can also be found in the apache config file).Koen.[/quote]I am currently hosted off site, and have a cPanel. Is there any way I can access the Apache's config file despite this?[!--quoteo(post=369033:date=Apr 26 2006, 06:02 PM:name=DepretioN)--][div class=\'quotetop\']QUOTE(DepretioN @ Apr 26 2006, 06:02 PM) [snapback]369033[/snapback][/div][div class=\'quotemain\'][!--quotec--]Make sure your upload_tmp_dir in your php.ini is set to the folder you are trying to upload that file to. Does the file upload anyway as this is just a warning?[/quote]Same problem, I'm not sure where I can access this file Quote Link to comment https://forums.phpfreaks.com/topic/8506-upload-form-difficulties/#findComment-31134 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 Hi,I'm not sure about cPanel, but with plesk the file resides under (your ftp root)/conf/vhost.conf). However, if this is a hosted environment there is no way that you will be able to write to the folder you set in above script as this seems like a vital folder on the server. You should just try adding a folder under your site root, set the permissions to 775 or 755, adjust your script to use a relative path:copy ("$file", "./my_upload_folder/".$file_name) and try again.koen Quote Link to comment https://forums.phpfreaks.com/topic/8506-upload-form-difficulties/#findComment-31142 Share on other sites More sharing options...
smc Posted April 26, 2006 Author Share Posted April 26, 2006 [!--quoteo(post=369043:date=Apr 26 2006, 06:16 PM:name=Koen Calliauw)--][div class=\'quotetop\']QUOTE(Koen Calliauw @ Apr 26 2006, 06:16 PM) [snapback]369043[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,I'm not sure about cPanel, but with plesk the file resides under (your ftp root)/conf/vhost.conf). However, if this is a hosted environment there is no way that you will be able to write to the folder you set in above script as this seems like a vital folder on the server. You should just try adding a folder under your site root, set the permissions to 775 or 755, adjust your script to use a relative path:copy ("$file", "./my_upload_folder/".$file_name) and try again.koen[/quote]Alright I'm working on getting that working. I've had a few syntax errors but I'm working on it. I'll let you know what happens[!--quoteo(post=369061:date=Apr 26 2006, 07:07 PM:name=SMC)--][div class=\'quotetop\']QUOTE(SMC @ Apr 26 2006, 07:07 PM) [snapback]369061[/snapback][/div][div class=\'quotemain\'][!--quotec--]Alright I'm working on getting that working. I've had a few syntax errors but I'm working on it. I'll let you know what happens[/quote]UPDATE:Alright it worked! Thank you very much for your help, and VERY much for your fast response!Have a great one,SMC Quote Link to comment https://forums.phpfreaks.com/topic/8506-upload-form-difficulties/#findComment-31160 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.