In PHP how can I create a form that has upload button, but it also has submit button where I submit that text from file and some other data (from other inouts)? Can I have two button elements in one form, or should I split my form into two forms, where one form has upload button, and another submit button? Should I use jQuery to upload file, but after that how can I access those data on action php file? Please help. Thank you
Share
No need for multiple forms. To upload a file use
<input type="file" name="MyFile">and add the following attribute to theformelement:enctype="multipart/form-data"After submitting the form to the server, you’ll get a
$_FILESsuper-global array (in addition to the $_POST array which will contain the rest of the fields), in which you’ll find all the details of the uploaded file. When you submit the form the file is uploaded to a temporary location, and you need to move it to its constant dwelling using themove_uploaded_file()function.