Forgive my ignorance in this..
I think I understand that using:
extract($_REQUEST);
in a php file will convert html form inputs into a corresponding variable. For instance:
<input type="text"name="author"/>
becomes:
$author
Is that right?
However, I’m confused as to how to handle a multipart form. For instance one with 1 file (an image) and two text inputs. How do I extract this data and put it into variables?
Okay, after another reading, your undeerstanding of extract is right.
But note that the
authorinput will generally be available as$_REQUEST["author"]anyway. Generally avoid to extract them all.If you for example want the value to be reused as form input you can write:
If you want to have shortnames, if for example it’s too many fields and it spares lots of typing, then I’d recommend using the optional parameters to extract():
This would generate a
$i_authorvariable, and all other input fields with a$i_prefix. This is believed to have less sideeffects with other (hyopthetical) local or global variables. Also you can usearray_map("htmlspecialchars",$_REQUEST)for extraction, if that aids the processing.Multipart form data will fill up the $_FILES array additionally, which has a different structure. See PHP manual http://php.net/manual/en/features.file-upload.php