Jump to content

Archived

This topic is now archived and is closed to further replies.

smc

Upload Form difficulties

Recommended Posts

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]
<?php
if($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 4

Warning: 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 4
Could 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,
SMC

PS: I did set the permissions for both files to 777

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

×

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.