Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP mkdir failing without errors
    primarykey
    data
    text
    <p>I've am trying to set up a small file sharing server on my home's local network and am running into some big problems with the uploader. the step it seems to be failing on is the directory creation step however, when I first posted this there were no errors in the Apache log files however, that turned out to be the result of a permission problem with the lag files.</p> <p>this are the relevant log entries.</p> <pre><code>[Mon Mar 25 18:43:05 2013] [error] [client 10.0.0.17] PHP Warning: mkdir(): Permission denied in /server/upload_movie.php on line 10, referer: http://10.0.0.17/upload_movie.html </code></pre> <p>it confuses me because I have run sudo chmod 0777 /server/* sudo chmod 0777 /server with /server/ being the rood directory.</p> <p>my code is as follows</p> <pre><code>&lt;?php echo "starting". "&lt;br&gt;"; $allowedExts = array("mp4", "mpg", "avi", "mkv"); $extension = end(explode(".", $_FILES["uplodedfile"]["name"])); echo "filetype parsed". "&lt;br&gt;"; $path = "/downloads/movies/unsorted/"; echo "checking upload directory". "&lt;br&gt;"; if(!is_dir($path)){ echo "upload directory not found, creating..."; if (mkdir($path,0777,true)) { echo "directory creation complete". "&lt;br&gt;"; } else { echo "directory creation failed at ".$path."&lt;br&gt;"; } } echo "checking file". "&lt;br&gt;"; if (false) { echo "filetype and size passed". "&lt;br&gt;"; if ($_FILES["uplodedfile"]["error"] &gt; 0) { header('Location: upload_failure.php?file='.$_FILES["uplodedfile"]['name'].'&amp;error='.$_FILES["uplodedfile"]["error"]); exit(); } else { echo "Upload: " . $_FILES["file"]["name"] . "&lt;br&gt;"; echo "Type: " . $_FILES["file"]["type"] . "&lt;br&gt;"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;"; if (file_exists("upload/" . $_FILES["uplodedfile"]["name"])) { echo $_FILES["file"]["name"] . " already exists on server. ". "&lt;br&gt;"; } else { echo "creating perminant copy of file". "&lt;br&gt;"; move_uploaded_file($_FILES["uplodedfile"]["tmp_name"], $path."/" . $_FILES["uplodedfile"]["name"]); echo "Stored in: " . "movie_uploads/" . $_FILES["file"]["name"]. "&lt;br&gt;"; } } header('Location: upload_success.php?type=movie'); exit(); } else { echo "error:&lt;br&gt;"; echo "Type: " . $_FILES["file"]["type"] . "&lt;br&gt;"; echo "Name: " . $_FILES["file"]["name"] . "&lt;br&gt;"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;"; echo "extension: ".$extension; exit(); // echo "Invalid file"; } ?&gt; </code></pre> <p>the output is as follows</p> <pre><code>starting filetype parsed checking upload directory upload directory not found, creating...directory creation failed at /downloads/movies/unsorted/ checking file error: Type: Name: Size: 0 kB Temp file: extension: </code></pre> <p>and the code calling it is </p> <pre><code>&lt;form enctype="multipart/form-data" action="upload_movie.php" method="POST"&gt; &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt; &lt;input type="submit" value="Upload File" /&gt; &lt;/form&gt; </code></pre> <p>i have tried all the suggestions in <a href="https://stackoverflow.com/questions/5246114/php-mkdir-permission-denied-problem">PHP mkdir: Permission denied problem</a> and I have selinux turned off. I am using fedora 17. the server is being run on an ext4 partition which contains nothing else.</p> <p>as was suggested in comments, i tried $error = error_get_last(); echo $error['message']; which yealded Undefined index: file</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload