I'm trying to upload two files with two different folders, but it is actually uploading the only second file. how to resolve this one?
private function _referal_image1( $type1, $type2, $img ) {
$tempname1 = __static__ .'referral_logo'. __ds__ . $type1;
$tempname2 = __static__ .'referral_background'. __ds__ . $type2;
move_uploaded_file($img, $tempname1);
move_uploaded_file($img, $tempname2);
$file_name1 = 'referral_logo'.__ds__.$type1;
$file_name2 = 'referral_background'.__ds__.$type2;
$combine = array($file_name1, $file_name2);
return $combine;
}
答案 0 :(得分:0)
You have this line twice:
move_uploaded_file($img, $tempname1);
move_uploaded_file($img, $tempname1);
You can't move the same file twice. You need to copy the file the 2nd time
move_uploaded_file($img, $tempname1);
copy($tempname1 , $tempname2);