PHP image upload using POST
I am trying to make a simple image loader. I have searched for hours and I made sure to set the enctype and I also changed my php.ini to match what I want to do. The file and folder permissions are also correct. I tried the same code on another webserver and it works. I am running apache2 with php5 on raspberry pi .
HTML code
<form method="post" enctype="multipart/form-data" action="upload.php">
<table>
<tr><td><input type="file" name="uimage"></td></tr>
<tr><td><input name="Submit" type="submit" value="Upload image"></td></tr>
</table>
</form>
PHP Code
var_dump($_FILES);
PHP code returns an empty array. var_dump($_POST);
works fine. On the other server both are running and the image upload is successful. I am assuming it is related to my server. I checked the php.ini and 000-default file in the allowed sites, but really can't figure out what is causing the problem.
This is what the error.log from apache2 says:
PHP note: Undefined index: uimage in /var/www/dmz/dotpic/upload.php on line 48, referent: http: //localhost/upload.php
Edit:
By "POST" in the title of the question, I mean the form method I am using. I am not trying to access the image using an array $_POST
. Sorry for this.
source to share
use $_FILES['uimage']
to access your file, $ _POST doesn't work for files. more details about this link: http://www.w3schools.com/php/php_file_upload.asp
source to share