Download two files using PHP

I know that this may sound a relatively basic question, but I still wanted to ask. I need to upload two files at once, creating two input files in my form, one for each file. So far I have used a basic script for testing to upload a single file.

I also found some examples of how to upload files with multiple files, but in my case I have two fields to upload and I want the user to upload two files. After downloading, I wanted to save it onmy webserver. Any simple example would be helpful.

thank

+5
source share
1 answer

This is just a case of changing variable names and doing just 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 continue from there?

+2
source

All Articles