我正在使用以下脚本进行简单的文件上传:
$errors = '';
$target_path = "[PATH HERE]";
$target_path = $target_path . basename($_FILES['uploadFile']['name']);
if(move_uploaded_file($_FILES['uploadFile']['tmp_name'], $target_path)) {
$errors = "The file ". basename( $_FILES['uploadFile']['name']). " has been uploaded";
} else{
$errors = "There was an error uploading the file, please try again! Type: " . $_FILES['uploadFile']['type'];
}
出于某种原因,我上传文件时出错并且文件类型未显示。它似乎只获取没有扩展名的文件名(即“test”而不是“test.pdf”)。我确定这很简单,但是我做错了什么?