Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload two files using PHP [duplicate]

Tags:

php

upload

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

like image 973
125369 Avatar asked Nov 04 '22 05:11

125369


1 Answers

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?

like image 146
Grim... Avatar answered Nov 07 '22 22:11

Grim...