使用 PHP 上传两个文件
我知道这听起来可能比较基本的问题,但还是想问.我需要通过在我的表单中为每个文件创建两个文件输入来一次上传两个文件.到目前为止,我一直使用一个基本脚本来测试上传单个文件.
I know this may sound relatively basic question, but still wanted to ask. I need to upload two files at once by creating two file input in my form one for each file. Until now I have used a basic script for testing to upload a single file.
我还找到了一些如何上传多个文件的示例,但就我而言,我有两个上传字段,我希望用户上传这两个文件.上传后,我想将其保存在我的网络服务器上.任何简单的例子都会有很好的帮助.
I also found some examples how to upload muliple files, but in my case I am having two upload fields and I want the user to upload the two files. Once uploaded I wanted to save it onmy webserver. Any simple example would be of good help.
谢谢
推荐答案
这只是一个简单的情况,只是改变了变量名,然后把所有的事情都做了两次.
It's simply just a case of changing the variable names and doing everything twice.
HTML:
<input type="file" name="filea" />
<input type="file" name="fileb" />
PHP:
$filea = $_FILES['filea'];
$fileb = $_FILES['fileb'];
move_uploaded_file($filea['tmp_name'], '/path/to/your/destination/'.$filea['name']);
你能从那里继续吗?
相关文章