File Upload Script error. Help!!!

Hi, im trying to get this file upload script to work for my website, but it keeps sending me back this error:
Warning: move_uploaded_file(gallery/2004-2005/pics/anchorman01.jpg): failed to open stream: Permission denied in /hsphere/local/home/bulldog/centennialbulldogs.org/upload.php on line 24

Warning: move_uploaded_file(): Unable to move ‘/tmp/phpVbpouX’ to ‘gallery/2004-2005/pics/anchorman01.jpg’ in /hsphere/local/home/bulldog/centennialbulldogs.org/upload.php on line 24

i just can’t figure it out. I CHMOD the upload folder, the script, and it still wont work. Please help.

Here is the script:
[php]

<?php //Define some variables $dir = "gallery/2004-2005/pics/"; //Change this to the correct dir //MIME types to allow, Gif, jpeg, zip ::Edit this to your liking $types = array("image/gif","image/pjpeg","application/x-zip-compressed"); //Check to determine if the submit button has been pressed if(isset($_POST['submit'])){ //Shorten Variables $tmp_name = $_FILES['upload']['tmp_name']; $new_name = $_FILES['upload']['name']; //Check MIME Type if (in_array($_FILES['upload']['type'], $types)){ //Move file from tmp dir to new location move_uploaded_file($tmp_name,$dir . $new_name); echo " was uploaded sucessfully!"; }else{ //Print Error Message echo "File Was Not Uploaded!
"; //Debug $name = $_FILES['upload']['name']; $type = $_FILES['upload']['type']; $size = $_FILES['upload']['size']; $tmp = $_FILES['upload']['name']; echo "Name: $name
Type: $type
Size: $size
Tmp: $tmp"; } } else{ echo 'Could Not Upload Files'; } ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> 
  
  <fieldset> 
          <legend>Upload Files</legend> 
        
            
                
      <input type="file" name="upload" /> 
[/php]

MOD EDIT: Added PHP bb code tags
Please view http://phphelp.com/forums/viewtopic.php?t=2564 for tiips on posting.

As the error message suggests, you do not (or rather your webserver does not) have the appropriate permissions to complete the task.

Check to see that the user that your webserver runs as has the appopriate permissions to navigate to the source file and the ultimate destination. For directories, you will need at least Execute permissions, and of course for the file itself you will need read and write.

I have found that for the most part using CHMOD in your script doesn’t work. I almost always have to go in and CHMOD manually on the files/folders I need to access.

Maybe I am doing something wrong, but I get the same problems you have when I don’t FTP into my site and change them manually.

I have found that CHMOD does not work well in a windows environement, however, I have not had any problems in the *nix environment. If you are using a hosting company, it is possible that they have restricted the use of this function, however.

I believe the chmod() function is disabled if SAFE MODE is enabled on the server.

Sponsor our Newsletter | Privacy Policy | Terms of Service