Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Here's a check-list for file uploading in PHP:</strong></p> <ol> <li><p>Check php.ini for:<br> <code>file_uploads = On</code><br> <code>post_max_size = 100M</code><br> <code>upload_max_filesize = 100M</code></p> <ul> <li>You might need to use <code>.htaccess</code> or <code>.user.ini</code> if you are on shared hosting and don't have access to <code>php.ini</code>.</li> <li>Make sure you’re editing the correct ini file – use the <code>phpinfo()</code> function to verify your settings are actually being applied. </li> <li>Also make sure you don’t misspell the sizes - it should be <code>100M</code> <em>not</em> <code>100MB</code>.</li> </ul></li> <li><p>Make sure your <code>&lt;form&gt;</code> tag has the <code>enctype="multipart/form-data"</code> attribute. No other tag will work, it has to be your FORM tag. Double check that it is <em>spelled correctly</em>. Double check that multipart/form-data is surrounded by STRAIGHT QUOTES, not smart quotes pasted in from Word OR from a website blog (WordPress converts straight quotes to angle quotes!). If you have multiple forms on the page, make sure they both have this attribute. Type them in manually, or try straight single quotes typed in manually.</p></li> <li><p>Make sure you do not have two input file fields with the same <code>name</code> attribute. If you need to support multiple, put square brackets at the end of the name:</p> <pre><code>&lt;input type="file" name="files[]"&gt; &lt;input type="file" name="files[]"&gt; </code></pre></li> <li><p>Make sure your tmp and upload directories have the correct read+write permissions set. The temporary upload folder is specified in PHP settings as <code>upload_tmp_dir</code>.</p></li> <li><p>Make sure your file destination and tmp/upload directories do not have spaces in them.</p></li> <li><p>Make sure all <code>&lt;form&gt;</code>'s on your page have <code>&lt;/form&gt;</code> close tags.</p></li> <li><p>Make sure your FORM tag has <code>method="POST"</code>. GET requests do not support multipart/form-data uploads.</p></li> <li><p>Make sure your file input tag has a NAME attribute. An ID attribute is NOT sufficient! ID attributes are for use in the DOM, not for POST payloads.</p></li> <li><p>Make sure you are not using Javascript to disable your <code>&lt;input type="file"&gt;</code> field on submission</p></li> <li><p>Make sure you're not nesting forms like <code>&lt;form&gt;&lt;form&gt;&lt;/form&gt;&lt;/form&gt;</code></p></li> <li><p>Check your HTML structure for invalid/overlapping tags like <code>&lt;div&gt;&lt;form&gt;&lt;/div&gt;&lt;/form&gt;</code></p></li> <li><p>Also make sure that the file you are uploading does not have any non-alphanumeric characters in it.</p></li> <li><p>Once, I just spent hours trying to figure out why this was happening to me all of a sudden. It turned out that I had modified some of the PHP settings in <code>.htaccess</code>, and one of them (not sure which yet) was causing the upload to fail and <code>$_FILES</code> to be empty.</p></li> <li><p>You could potentially try avoiding underscores (<code>_</code>) in the <code>name=""</code> attribute of the <code>&lt;input&gt;</code> tag</p></li> <li><p>Try uploading very small files to narrow down whether it's a file-size issue.</p></li> <li><p>Check your available disk space. Although very rare, it is mentioned in this <a href="http://www.php.net/manual/en/function.is-uploaded-file.php#46257" rel="noreferrer">PHP Manual page comment</a>:</p> <blockquote> <p>If the $_FILES array suddenly goes mysteriously empty, even though your form seems correct, you should check the disk space available for your temporary folder partition. In my installation, all file uploads failed without warning. After much gnashing of teeth, I tried freeing up additional space, after which file uploads suddenly worked again.</p> </blockquote></li> </ol> <p><em>Source for some of these points:<br> <a href="http://getluky.net/2004/10/04/apachephp-_files-array-mysteriously-empty/" rel="noreferrer">http://getluky.net/2004/10/04/apachephp-_files-array-mysteriously-empty/</a></em></p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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