4 Replies - 1463 Views - Last Post: 31 May 2008 - 10:16 PM Rate Topic: -----

#1 gadgetsguru  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 07-October 06

Problems after using PHP upload script

Post icon  Posted 31 May 2008 - 02:26 PM

Hi everyone!
I created a PHP upload script and it is successful in uploading the files; however, when I try to access the files on my web hosting provider (Yahoo! Small Business), I get a 403 Forbidden error. Is this because of my script or is it something I need to contact Yahoo! Small Business about? Please help!

Below is the script I used...

<?php
if (array_key_exists('_submit_check', $_POST)) { // If uploaded file exists
 $uploadTo = "uploads/"; // Where the file is going to be placed

 /* Add the original filename to our target path.
 Result is "uploads/filename.extension" */
 $uploadTo = $uploadTo . basename($_FILES['userfile']['name']);
 $_FILES['userfile']['tmp_name'];
}
?><html>
<head>
 <title>Upload script</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post">
 <input type="hidden" name="_submit_check" value="1">
 <input type="hidden" name="MAX_FILE_SIZE" value="4194304">
 File: <input name="userfile" type="file"> <input type="submit" value="Upload">
</form>
<?php
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadTo)) {
?>The file <a href="<?php echo $uploadTo; ?>" target="_top"><strong><?php echo basename($_FILES['userfile']['name']); ?></strong></a> was successfully uploaded.<?php
} elseif (array_key_exists('_submit_check', $_POST) && !move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadTo)) {
?>There was an error uploading the file, please try again!<?php } ?>
</body>
</html>


Thank you for your help! I really do appreciate it. :D

This post has been edited by gadgetsguru: 31 May 2008 - 03:10 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Problems after using PHP upload script

#2 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: Problems after using PHP upload script

Posted 31 May 2008 - 05:14 PM

you would need to talk to the hosting company. it sounds like they won't allow access, and the server would need to be edited to allow it.
Was This Post Helpful? 0
  • +
  • -

#3 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 89
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: Problems after using PHP upload script

Posted 31 May 2008 - 05:41 PM

How are you trying to access the files?

Are you just trying to browse to 'http://www.yourdomain.com/uploadedfiles/' or wherever your files are stored?

If so, that's why you're getting the 403 error. 403 errors are regarding permissions, so they may not be set properly on your server. However, if you are try to access the directory as above, the 403 will get thrown for trying to access a directory without an index file. Try accessing your files with

http://www.yourdomai...es/filename.txt

Or whatever your filename is.

Hope that helps clarify a bit more.
Was This Post Helpful? 0
  • +
  • -

#4 gadgetsguru  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 07-October 06

Re: Problems after using PHP upload script

Posted 31 May 2008 - 08:46 PM

View Postakozlik, on 31 May, 2008 - 06:41 PM, said:

How are you trying to access the files?

Are you just trying to browse to 'http://www.yourdomain.com/uploadedfiles/' or wherever your files are stored?

If so, that's why you're getting the 403 error. 403 errors are regarding permissions, so they may not be set properly on your server. However, if you are try to access the directory as above, the 403 will get thrown for trying to access a directory without an index file. Try accessing your files with

http://www.yourdomai...es/filename.txt

Or whatever your filename is.

Hope that helps clarify a bit more.

Actually, I can access the folder just fine, but when I try to access the specific file, that's when I get the 403 Forbidden error. I think it does have something to do with permissions, but I'll have to start looking into that. I haven't the slightest idea on how to get/set file permissions. lol!

Anyways, thanks for the info! :-)
Was This Post Helpful? 0
  • +
  • -

#5 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 89
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: Problems after using PHP upload script

Posted 31 May 2008 - 10:16 PM

Does your ftp client allow for setting permissions? If so you should right click on the directory and set the permissions to full read/write/execute. If you can SSH into the site you could also chown the directory with

chown directory 777



If anything, check with your hosting service. You should be able to access files that are uploaded.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1