Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - File Upload spitting out error
    primarykey
    data
    text
    <p>I was working on a simple file upload exercise i've gotten from my WebDev Class - We actually only had to copy the code and integrate it to fit our needs. I tried to do so for my project, sadly it will keep on echoing out the same error.</p> <pre><code>&lt;?php $allowed_filetypes = array('.jpg','.gif','.bmp','.png', '.jpeg'); $max_filesize = 524288; $upload_path = 'uploads/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); var_export($_FILES, $ext); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['usrfile']['tmp_name']) &gt; $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['usrfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file &lt;a href="' . $upload_path . $filename . '" title="Your File"&gt;here&lt;/a&gt;'; else echo 'There was an error during the file upload. Please try again.'; ?&gt; </code></pre> <p>It keeps on giving me the 'wrong filetype' error, with all of defined types in the array.</p> <pre><code>&lt;form id='upload' action="uploadfile.php" method="POST" enctype="multipart/form-data"&gt; &lt;table&gt; &lt;tr&gt; &lt;td &gt;Choose a File to Upload&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td &gt;Select File&lt;/td&gt; &lt;td &gt;&lt;input type="file" name="userfile"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=2 id="sub"&gt;&lt;input type="submit" name="submit" value="submit" &gt;&lt;/td&gt; &lt;/tr&gt; &lt;/Table&gt; &lt;/form&gt; </code></pre>
    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.
    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