move_uploaded_file不在远程服务器上工作但在本地服务器上工作

时间:2016-11-01 08:37:40

标签: php html upload

我真的不知道我在这里做错了什么。我有一个图片上传页面。它在localhost上工作得很好,但是一旦我将它上传到远程服务器,它就不能按我的意愿工作了。我已经更改了文件夹权限,我已经更改了直接仍然无法正常工作。它没有给我任何错误。它显示文件上传成功,但无论何时我检查文件夹,它都是空的。请帮帮我。这是我的代码。

if(isset($_POST['upload'])) 
{ 
  $tmp_name = $_FILES['passport']['tmp_name']; 
  if (empty($tmp_name) == false){
      $name = $_FILES['passport']['name']; 
      $type = $_FILES['passport']['type']; 
      $size = $_FILES['passport']['size']; 
      list($width, $height, $typeb, $attr) = getimagesize($tmp_name); 

     if($width<=160 || $height<=160) 
     { 
        if($type=='image/jpeg' || $type=='image/jpg' || $type=='image/png')
        {
            if($size<='20000') 
            { 
                if(!get_magic_quotes_gpc())
                { 
                    $name = addslashes($name); 

                    $extract = fopen($tmp_name, 'r'); 
                    $content = fread($extract, $size); 
                    $content = addslashes($content); 
                    fclose($extract);  
                    //Place image in the folder
                    $newname="$studentID.jpg";
                    move_uploaded_file($_FILES['passport']['tmp_name'],"../passports/$newname");
                    $msg = "<center><p style ='color: #4F8A10; background-color: #DFF2BF; border-radius:.5em; width: 350px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase; padding-left: 12px'>Passport uploaded successfully.. Click the link below to continue</p></center>";
                } else {
                    $uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>Error has occured... Please try again</p>"; 
                }
            } else {
                $uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>$name is more than 20kb</p>"; 
            }
        } else {
            $uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>$type is not in acceptable format</p>"; 
        } 
    } else {
        $uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>$name should be 160px * 160px</p>"; 
    }
} else {
    $uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>Please choose a file to upload</p>"; 
  }
}

0 个答案:

没有答案