【发布时间】:2016-02-17 04:57:32
【问题描述】:
大家好,我正在尝试在 php 中上传文件。但它没有上传文件
这里是代码
$excel = new PhpExcelReader;
if(isset($_POST["submit"]))
{
$target_dir="../upload/";
$target_path=$target_dir.basename($_FILES['fileToUpload']['name']);
//move_uploaded_file($_FILES['fileToUpload']['name'],$target_path);
if(move_uploaded_file($_FILES['fileToUpload']['name'],$target_path))
{
echo basename($_FILES['fileToUpload']['name']);
}
else
{
echo "Possible file upload attack!\n";
}
print_r($_FILES);
/* $handle = realpath($_FILES["fileToUpload"]["name"]);
$excel = new PhpExcelReader;
$excel->read($handle);
echo $handle; */
}
这段代码总是让我陷入 else 状态。在我的 html 表单中,我还添加了 enctype="multipart/form-data" 并检查了我的 $_FILES 数组中的 $_FILES 数组,我得到了这个
Array ( [fileToUpload] => Array ( [name] => Book1.xlsx [type] 的副本 => application/vnd.openxmlformats-officedocument.spreadsheetml.sheet [tmp_name] => H:\PHP\xampp\tmp\phpF54F.tmp [error] => 0 [size] => 第13459章
【问题讨论】:
标签: php file-upload