Upload two files using PHP

孤者浪人 提交于 2019-12-19 20:09:25

问题


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.

Thanks


回答1:


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']);

Can you carry on from there?



来源:https://stackoverflow.com/questions/9291061/upload-two-files-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!