The code looks fine except for the form tag and your field names.
HTML Code:
<form name="formName" method="POST" action="some/URL.php" enctype='multipart/form-data'>
- action: a URL where the form is processed , by defaul it ges to the same page the form is in
- method: GET or POST goes here, by defauly it's GET. Since you are upping files, you really will need POST.
- enctype='multipart/form-data' is needed because you are upping files!
When a form gets submitted the element name is what gets passed as a variable name for that field. So naming the file imputs the same name, actually uploads 3 files but overrides the first two! nice, eh?
You can use different names , but best practice is to make it an array, name='datafile[]'. When you process the form in the back end you can iterate through 'datafile', the first one will be datafile[0], second will be datafile[1], third datafile[2] and so forth...
it's also good to have a name on the submit button that way its value will be passed on submission as such you can use that ON THE POSSESSING PAGE to see if the form has been submitted.
PHP Code:
<php? if (!isset($_POST['sub'])){ echo "uh oh, you are here but you didnt press submit!!!";} ?>
oh .. and this is just added info....
depending on how you are styling this you could put all the inputs in just one div.
HTML Code:
<form name="formName" method="POST" action="some/URL.php" enctype='multipart/form-data'>
<div>
<input type="file" name="datafile" value="Upload" ><br>
<input type="file" name="datafile" value="Upload" ><br>
<input type="file" name="datafile" value="Upload" ><br>
<input type="submit" name='submit' value="Send">
</div>
</form>
Bookmarks