Simultaneous Image Uploads

Hi guys…

I’m developing a backend and I need to upload 2 images at the same time.

I got it to work with only one image upload. But I can’t figure out how to do this with 2 input file type fields at the same time.

Here is what I’m working with:

[code]$fimage=$_FILES[‘fimage’][‘name’];
$fthumb=$_FILES[‘fthumb’][‘name’];

//upload file
$target_path = “upload/”;

$target_path = $target_path . basename( $_FILES['fimage']['name']); 

if(move_uploaded_file($_FILES['fimage']['tmp_name'], $target_path)) {
	echo "The file ".  basename( $_FILES['fimage']['name']). 
	" has been uploaded";
} else{
	echo "There was an error uploading the file, please try again!";
}

//end upload file[/code]

if its exactly 2 u may just use:
[php]$fimage=$_FILES[‘fimage’][‘name’];
$fthumb=$_FILES[‘fthumb’][‘name’];

//upload file1
$target_path = “upload/”;

$target_path = $target_path . basename( $_FILES[‘fimage’][‘name’]);

if(move_uploaded_file($_FILES[‘fimage’][‘tmp_name’], $target_path)) {
echo "The file “. basename( $_FILES[‘fimage’][‘name’]).
" has been uploaded”;
} else{
echo “There was an error uploading the file, please try again!”;
}
//end upload file1

//upload file2
$target_path = “upload/”;

$target_path = $target_path . basename( $_FILES[‘fthumb’][‘name’]);

if(move_uploaded_file($_FILES[‘fthumb’][‘tmp_name’], $target_path)) {
echo "The file “. basename( $_FILES[‘fthumb’][‘name’]).
" has been uploaded”;
} else{
echo “There was an error uploading the file, please try again!”;
}
//end upload file2[/php]

Thank you so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service