I am initializing file upload using the following HTML:
<form enctype="multipart/form-data" action="PHPScripts/upload.php" method="POST">
<input type="file" id="browseButton" name="image" onchange="this.form.submit();" />
</form>
Upload.php script looks like this:
<?php
$file = $_FILES["image"];
$filepath = $file["name"];
$filetmp = $file["tmp_name"];
$filesize = $file["size"];
$filename = basename($filepath);
$filetype = substr($filename, strrpos($filename, ".") + 1);
...
?>
I need to pass one more parameter to my php script, but I don't know how. HTTP method is POST (as can be seen in the code above), but where should I put the parameter? Is that even possible? Thanks for clarifying this to me.
Make sure that the form uses method="post" The form also needs the following attribute: enctype="multipart/form-data".
tmp_name is the temporary name of the uploaded file which is generated automatically by php, and stored on the temporary folder on the server. name is the original name of the file which is store on the local machine.
Two PHP configuration options control the maximum upload size: upload_max_filesize and post_max_size . Both can be set to, say, “10M” for 10 megabyte file sizes. However, you also need to consider the time it takes to complete an upload.
Just add another input
element of your choice. No additional magic required.
<input type="hidden" name="info" value="Test">
...
$info = $_POST["info"];
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