I'm trying to upload two files from single form. However it's not getting uploaded to the folder location, I'm not able to find the error, too.
Here is my code:
HTML File
<form action='/uploadfile.php' method='post' enctype='multipart/form-data'>
<input type='file' name='photograph'>
<input type='file' name='addressproof'>
<input type='submit' class="button alt" value='SAVE'>
</form>
uploadfile.php
if($_FILES['photograph']['error']==0){
$info = pathinfo($_FILES['photograph']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = "photograph_".$userid.".".$ext;
if($ext=='jpg' || $ext=='png' || $ext=='jpeg' || $ext=='pdf'){
$target = '/user_documents/photograph/'.$newname;
move_uploaded_file( $_FILES['photograph']['tmp_name'], $target);
}
}
if($_FILES['addressproof']['error']==0){
$info = pathinfo($_FILES['addressproof']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = "address_proof_".$userid.".".$ext;
if($ext=='jpg' || $ext=='png' || $ext=='jpeg' || $ext=='pdf'){
$target = '/user_documents/address_proof/'.$newname;
move_uploaded_file( $_FILES['addressproof']['tmp_name'], $target);
}
}
Can somebody help identify the error?