0

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?

2
  • do your folder have 777 permission? Commented Sep 7, 2015 at 10:48
  • Yes they have 777 permission Commented Sep 7, 2015 at 10:51

1 Answer 1

1
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; // remove the slash before user_documents/address_proof/ move_uploaded_file( $_FILES['addressproof']['tmp_name'], $target); } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.