View Full Version : help in joining 2 uploaded files

04-25-2006, 04:30 PM
Hi guys,Does anyone know how to join the 2 uploaded files together under the variable $FileName?

$FileName=$UploadDir.$_FILES['uploadedfile1']['name'] $UploadDir.$_FILES['uploadedfile2']['name'];

04-25-2006, 04:55 PM
not entirely sure what you are asking since your pseudo code suggest you wnat to merge the filenames..

// merge filenames
$FileName= $UploadDir.$_FILES['uploadedfile1']['name'].$UploadDir.$_FILES['uploadedfile2']['name'];
but maybe you meant you want to join the files together..

// merge file
$FileName= file_get_contents($_FILES['uploadedfile1']['tmp_name']).file_get_contents($_FILES['uploadedfile2']['tmp_name']);

04-26-2006, 07:11 AM
I think it should work but i have another error with the array stuff.

Warning: Wrong parameter count for in_array() in test.php on line 8

$FileTypes=array("image/jpg", "image/gif", "image/jpeg", "image/pjpeg");
// Check to ensure the uploaded file is of correct type
if (in_array($_FILES['uploadfile1']['type'],$FileTypes and $_FILES['uploadfile2']['type'],$FileTypes))

04-26-2006, 02:08 PM
if (in_array($_FILES['uploadfile1']['type'],$FileTypes) && in_array($_FILES['uploadfile2']['type'],$FileTypes))

you should also be checking the file extension.. a mime type can be easily forged.

04-27-2006, 12:21 PM
i see.how do i check for extension?