问题描述
我知道这可能听起来比较基础的问题,但还是想问.我需要通过在我的表单中为每个文件创建两个文件输入来一次上传两个文件.到目前为止,我使用了一个基本的脚本来测试上传单个文件.
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']);
你能从那里继续吗?
这篇关于使用PHP上传两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!