Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple upload file form not working with some browsers
    primarykey
    data
    text
    <p>I have a problem with upload file forms. I'll write here a simple example of code which is not working in all the browser.</p> <p>HTML part is something like this:</p> <pre><code> &lt;form method="POST" enctype="multipart/form-data" action="match.php"&gt; &lt;input class="btn btn-info" name="dataset" type="file" id="dataset" /&gt; &lt;input class="btn btn-info" type="submit" name="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>Then, then in match.php file I get and process the file, for example like this:</p> <pre><code>if ($_FILES["dataset"]["error"] &gt; 0 || !($_FILES["dataset"]["size"] &gt; 0)) { $dataset = "default.txt"; echo 'error:' . $_FILES["dataset"]["error"] . ' - filesize:' . $_FILES["dataset"]["size"]; } else { $dataset = $_FILES["dataset"]["tmp_name"]; echo "Ok"; print_r($_FILES); } </code></pre> <p>Very easy: if there are errors during the upload process I will use a default file (and print some error information), otherwise everything's ok.</p> <p>Well, this works perfectly except in some browsers. For example I encountered the problem with <strong>Android default browser</strong> (not with Chrome), and it seems with some browsers in Windows systems too (I didn't tried it by myself, to be sincere).</p> <p>Using error information I print, it looks like there's no error in <code>$_FILES["dataset"]["error"]</code> (output is 0), but the filesize is <strong>0</strong> (just on these browsers).</p> <p>There's no problem with folders permissions (I write files in folders using "default.txt" file information), there's no problem with <strong>php.ini</strong> settings (actually I tested it with the same txt file which is 65kb).</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.
    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