开发者

Is it possible to send additional parameters when uploading a file in PHP?

开发者 https://www.devze.com 2023-02-11 02:38 出处:网络
I am initializing file upload using the following HTML: <form enctype=\"multipart开发者_Go百科/form-data\" action=\"PHPScripts/upload.php\" method=\"POST\">

I am initializing file upload using the following HTML:

<form enctype="multipart开发者_Go百科/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.


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

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

...

$info = $_POST["info"];


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

0

精彩评论

暂无评论...
验证码 换一张
取 消