<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br />
<form action="getfile.php" method="post"><br />
Type (or select) Filename:
<input type="file" name="uploadFile" />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
I am working on a php language . I am uploading a pic from my computer . But there are two buttons ie choose file and Upload file . CHOOSE FILE is used to select the picture from PC and upload file button is used as SUBMIT button but i need a single button by clicking on it it will open my pc window to browse the photos and select it and it also act as a submit button . Is there any way to do this with single button
you need to change to things in your form tag:
1) Add a name tag: say name="frm"
2) enctype="multipart/form-data"
Then in your input file type add a function onchange="frm.submit();" // Where frm is name of the form
You can wait an event change on the input type="file" and send file after this event.
If you use jQuery, you can send the form with .submit().
Try with something like this
$("input[type='file']").on("change", function(){
$("form").submit();
});
.on("change", handler) : http://api.jquery.com/change/
.submit() : http://api.jquery.com/submit/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With