PHP 上传文件时是否可以发送附加参数?
我正在使用以下 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 脚本如下所示:
<?php
$file = $_FILES["image"];
$filepath = $file["name"];
$filetmp = $file["tmp_name"];
$filesize = $file["size"];
$filename = basename($filepath);
$filetype = substr($filename, strrpos($filename, ".") + 1);
...
?>
我需要再向我的 php 脚本传递一个参数,但我不知道如何传递。 HTTP方法是POST(如上面的代码所示),但是参数应该放在哪里呢?这可能吗?感谢您向我澄清这一点。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需添加您选择的另一个
input
元素即可。不需要额外的魔法。...
Just add another
input
element of your choice. No additional magic required....
只需将一个元素放入文件输入所在的同一表单中?
Just put one element inside the same form where the file input is?