上传文件php时返回false

时间:2018-09-13 15:10:53

标签: php mysql

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

0 个答案:

没有答案