Jump to content


Photo

Move_Uploaded_files Problem!?


  • Please log in to reply
4 replies to this topic

#1 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 08 July 2006 - 02:09 AM

Warning: move_uploaded_file(./storage/upload/e40f5ba010bdb23143e5ea85d9e61611.html): failed to open stream: Permission denied in /home/*/public_html/upload.php on line 44

Warning: move_uploaded_file(): Unable to move '/tmp/php2ITsmd' to './storage/upload/e40f5ba010bdb23143e5ea85d9e61611.html' in /home/*/public_html/upload.php on line 44
Error uploading file


<?
$uploadDir = './storage/upload/';


if(isset($_POST['upload']))
{
    $fileName = $_FILES['userfile']['name'];
    $tmpName  = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];
    $category = $_POST['category'];

    $ext      = substr(strrchr($fileName, "."), 1);


    $randName = md5(rand() * time());


    $filePath = $uploadDir . $randName . '.' . $ext;

    $result = move_uploaded_file($tmpName, $filePath);         <----- LINE 44
    if (!$result) {
        echo "Error uploading file";
        include 'footer.php';
        exit;
    }

     if (!$category) { echo "You must Select a category!";
     include 'footer.php';
     exit; }

    if(!get_magic_quotes_gpc())
    {
        $fileName  = addslashes($fileName);
        $filePath  = addslashes($filePath);
        $category = addslashes($category);
    }

    $query = "INSERT INTO upload (name, size, type, path, uploader, category) ".
             "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$member','$category')";

    mysql_query($query) or die('Error, query failed : ' . mysql_error());

     
    echo "<br>File uploaded<br>";
 }
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
  <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
    <tr>
      <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="4000000000"><input name="userfile" type="file" class="box" id="userfile">
         </td> <td width="350" border="0" cellpadding="1" cellspacing="1">
         <select name="category" size="5">
<option value="Movie">Movie</option>
<option value="Hacks">Hacking</option>
<option value="Audio">Music</option>
<option value="Applications">Applications</option>
<option value="Windows">\/\/  ! /\/ |) () \/\/ S</option>
<option value="Papers">White Papers</option>
<option value="AllinOnes">All in Ones</option>
</select></td>
      <td width="80"><input name="upload" type="submit" class="box" id="upload" value="  Upload  "></td>
        </tr>
  </table>
</form>

</body>
</html>
</div>              <? include 'footer.php'; ?>
 

Any ideas what is wrong? I can't figure it out  ???

#2 Kurt

Kurt
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts
  • LocationNew York

Posted 08 July 2006 - 02:11 AM

You need to set the permissions of the folder you wish to upload to to 777.

#3 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 08 July 2006 - 02:14 AM

I did...that's the wierd thing..

#4 Kurt

Kurt
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts
  • LocationNew York

Posted 08 July 2006 - 02:16 AM

I did...that's the wierd thing..

Well, you're getting a "permission denied" which means it isn't writeable. Check to make sure it is writable by debugging it using the is_writable() function.

#5 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 08 July 2006 - 02:16 AM

Oh..i lied heh...i had it 766 Thanks :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users