Jump to content


This topic is now archived and is closed to further replies.


Move_Uploaded_files Problem!?

Recommended Posts

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/';

    $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';

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

        $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">
      <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>
      <td width="80"><input name="upload" type="submit" class="box" id="upload" value="  Upload  "></td>

</div>              <? include 'footer.php'; ?>[/code] 

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

Share this post

Link to post
Share on other sites
You need to set the permissions of the folder you wish to upload to to 777.

Share this post

Link to post
Share on other sites
[quote author=lordphate link=topic=99838.msg393402#msg393402 date=1152324868]
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.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.