我的问题是我试图上传一个带有php代码的文件,但是 move_uploaded_file()
函数返回false。我做错什么了?
我的php代码:
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: multipart/form-data");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
$destFile = "/root/mysite/upload_files/";
if( $_FILES['avatar']['name'] != "" )
{
$tmpFilePath = $_FILES['avatar']['tmp_name'];
$fileName = basename($_FILES["avatar"]["name"]);
move_uploaded_file($tmpFilePath, $destFile . $fileName);
}
?>
1条答案
按热度按时间mpbci0fu1#
试试下面这样的。