Jump to content

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


[code]<?
$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'; ?>[/code] 

Any ideas what is wrong? I can't figure it out  ???
Link to comment
https://forums.phpfreaks.com/topic/13995-move_uploaded_files-problem/
Share on other sites

[quote author=lordphate link=topic=99838.msg393402#msg393402 date=1152324868]
I did...that's the wierd thing..
[/quote]
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.