Question

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.

Was it helpful?

Solution

Just add another input element of your choice. No additional magic required.

 <input type="hidden" name="info" value="Test">

...

$info = $_POST["info"];

OTHER TIPS

Just put one element inside the same form where the file input is?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top