PHP警告:move_uploaded_file():无法移动

时间:2017-02-19 11:10:52

标签: php

我是php& amp;的初学者试图建立一个小应用程序。 下面的部分在php页面上成功运行,我们没有除此之外的任何代码。当我在上面的其他php表单上使用相同的代码时出现错误" move_uploaded_file():无法移动"来了。

if(isset($_FILES['file'])) {

    $file=$_FILES['file'];
    //files properties
    $file_name = $file['name'];
    $file_tmp = $file['tmp_name'];
    $file_size = $file['size'];
    $file_error = $file['error'];
    // work out the files extension
    $file_ext = explode('.',$file_name);
    $file_ext = strtolower(end($file_ext));
    $allowed = array('doc','docx','pdf','rtf','txt');
    //print_r($file_ext);
    if(in_array($file_ext,$allowed))
    {
        if($file_error==0)
        {
            if($file_size<=5000000)
            {
                $file_name_new=uniqid('',true).'.'.$file_ext;
                $file_destination = '/./Resume/'.$file_name_new;
                //$_SESSION['message']= $file_tmp; 
                if(move_uploaded_file($file_tmp,$file_destination))
                {
                    echo"file uploaded sucessfully";
                }
                else
                {
                    $_SESSION['message']= "File not uploaded to the destination".$file_name;
                }
            }
            else
            {
            $_SESSION['message']= "Files size is more than 5 MB";
            }
        }
        else
        {
            $_SESSION['message']= "some unexpected error happened";
        }
    }
    else
    {
        $_SESSION['message']= "Please upload file matching the below extensions only"; 
    }

}

0 个答案:

没有答案