Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Exclamation User Upload Problem? Identify Please.

    Hi,

    I have been having problems allowing users to upload their files on my site into my file manager upload/ directory. When I tried I got this:
    Upload: circle-unit-304560.gif
    Type: image/gif
    Size: 12.181640625 Kb
    Temp file: /usr/local/pem/vhosts/113282/tmp/phpTeKNv1
    Warning: move_uploaded_file(upload/circle-unit-304560.gif): failed to open stream: Permission denied in /usr/local/pem/vhosts/113282/webspace/httpdocs/upload_file.php on line 25 Warning: move_uploaded_file(): Unable to move '/usr/local/pem/vhosts/113282/tmp/phpTeKNv1' to 'upload/circle-unit-304560.gif' in /usr/local/pem/vhosts/113282/webspace/httpdocs/upload_file.php on line 25 Stored in: upload/circle-unit-304560.gif

    The code used was

    HTML form:

    Code:
    <html lang="en">
    	
    	<body>
    		
    		<form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" /> 
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    		
    	</body>
    </html>
    PHP handler:

    PHP Code:
    <?php
    if ((($_FILES["file"]["type"] == "image/gif")
    || (
    $_FILES["file"]["type"] == "image/jpeg")
    || (
    $_FILES["file"]["type"] == "image/pjpeg"))
    && (
    $_FILES["file"]["size"] < 20000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo 
    "Upload: " $_FILES["file"]["name"] . "<br />";
        echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
        echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo 
    "Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

        if (
    file_exists("upload/" $_FILES["file"]["name"]))
          {
          echo 
    $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "upload/" $_FILES["file"]["name"]);
          echo 
    "Stored in: " "upload/" $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo 
    "Invalid file";
      }
    ?>
    Can you identify the problem or offer a solution please. I know this looks like I am asking you to design my website but I can't seem to get past this hurdle.

    Thanks, Eric

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Yeah I double checked

  • #3
    New Coder
    Join Date
    Aug 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Haha I don't know... i've never worked with this hosting site before... Would those be the only two problems? Thanks for the replies

  • #4
    Regular Coder
    Join Date
    Sep 2009
    Location
    Calgary, Alberta
    Posts
    241
    Thanks
    48
    Thanked 3 Times in 3 Posts
    I would think the folder you are moving the file to is not set to be writable.

    Check the permissions of the folder to make sure it is set to 777 or 0777

    Chmod 777

    Thanks SlayerACC.

  • Users who have thanked SlayerACC for this post:

    loopsnhoops (04-25-2012)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •