Jump to content


Photo

Upload Form difficulties


  • Please log in to reply
5 replies to this topic

#1 smc

smc
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 26 April 2006 - 09:55 PM

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:

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

Now this is the error message I get when trying to upload:

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

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
mysql_query( "UPDATE suntrust SET level = 'rich_sucka' WHERE bank_account = 'mine' AND dollars = '0'" ) or DIE;

#2 koencalliauw

koencalliauw
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 April 2006 - 10:02 PM

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.

#3 DepretioN

DepretioN
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 26 April 2006 - 10:02 PM

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?

#4 smc

smc
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 26 April 2006 - 10:08 PM

[!--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) View Post[/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) View Post[/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
mysql_query( "UPDATE suntrust SET level = 'rich_sucka' WHERE bank_account = 'mine' AND dollars = '0'" ) or DIE;

#5 koencalliauw

koencalliauw
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 April 2006 - 10:16 PM

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

#6 smc

smc
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts

Posted 26 April 2006 - 11:13 PM

[!--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) View Post[/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) View Post[/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
mysql_query( "UPDATE suntrust SET level = 'rich_sucka' WHERE bank_account = 'mine' AND dollars = '0'" ) or DIE;




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users