0
我試圖從單一表單上傳兩個文件。然而,它沒有上傳到文件夾位置,我也無法找到錯誤。從一個表單上傳多個文件php
這裏是我的代碼:
HTML文件
<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);
}
}
有人可以幫助找出錯誤?
做你的文件夾有777權限? –
是的,他們有777許可 –