Reputation: 1526
I am doing a simple form in html to upload an image
In chrome is working properly but in firefox for some reason the variable $_POS
T is empty
This is my form
<form action="do_upload.php" method="POST" enctype="multipart/form-data">
<fieldset>
<p>Select a section</p>
<select name="section" required>
<option value="">Please Select</option>
<option value="0">Announcements</option>
<option value="1">Circulars</option>
<option value="2">Corportate Governance</option>
<option value="3">Financial Report</option>
</select>
<p>Date</p>
<input type="text" name="date" required>
<p>Title</p>
<input type="text" name="title" required>
<p>Search your file</p>
<input type="file" name="pdf" required>
<div class="sep"></div>
<button type="submit">Do it!</button>
</fieldset>
</form>
And in my file do_upload.php I have only this:
print_r($_POST);
Even I fill all the form I always get the array $_POST
empty
I know that to get the file I need to use the global $_FILE
, I just want to know why firefox show me an empty array when I use input type file.
Any idea? I should be able to get this:
Array ( [section] => 3 [date] => 07/05/2016 [title] => 123 )
Upvotes: 0
Views: 281
Reputation: 12085
Whenever you do a file upload, the files get populated in the $_FILES global variable, and the other fields get populated in the $_POST global variable.
echo $_FILES['pdf']['name'];
Upvotes: 0
Reputation:
If your input type is file
you have to access the value on serverside via $_FILES["pdf"]
.
Description
An associative array of items uploaded to the current script via the HTTP POST method. The structure of this array is outlined in the POST method uploads section.
See: http://php.net/manual/en/reserved.variables.files.php
And: http://php.net/manual/en/features.file-upload.post-method.php
Upvotes: 1