I have a form.
In the form, there is an image upload plus a series of checkboxes.
I am trying to loop through the $_POST vars to process them.
When I do
foreach($_POST as $key => $value){echo "$key $value"; }
I only get ‘input’ $_POST vars outputted. The checkbox values and the image upload value are not.
I am utilizing Code Igniter as a Framework.
Any ideas?
Thanks
You should get any checked checkboxes as part of your
$_POSTarray. Unchecked checkboxes will be absent.Images uploaded (from
<input type="file" />fields) will be in the$_FILESarray, if and only if you set your formenctypeto "multipart/form-data" (see here).To get started handling file uploads in PHP, there’s an excellent tutorial on W3Schools.
Given the HTML:
If you want to get the filename of the uploaded file (i.e. the name of the file as it was on the user’s PC), you want:
If you want the name of the uploaded file on your server, you want:
You may also find the documentation on
move_uploaded_filehelpful.