我使用下面的代碼來訪問html 5攝像頭並將圖片上傳到服務器。HTML 5使用php的攝像頭訪問和上傳文件
HTML代碼
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" capture>
<input type="submit" value="Upload">
</form>
upload.php的代碼
<?php
$target_path = "upload/";
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
問題是,當我測試它顯示的代碼「有一個上傳文件時出錯,請重試!」 。任何人都可以幫我弄清楚問題出在哪裏?
下面的代碼適合我。
HTML代碼:
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
PHP代碼是與上述相同。
在此先感謝。
'move_uploaded_file()'的輸出是什麼?您可能無權將文件放入目標文件夾或發生其他錯誤。檢查你的錯誤日誌。 – chrki 2013-02-17 11:51:00