我的问题是我正在尝试使用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);
}
?>