簡體   English   中英

文件上傳在實時服務器上不起作用

[英]File uploading is not working on live server

警告:move_uploaded_file(/images/24_silver_2_1.jpg):無法打開流:第72行的C:\\ Inetpub \\ vhosts \\ leojungen.com \\ httpdocs \\ launch-complaint.php中沒有此類文件或目錄

警告:move_uploaded_file():無法將C:\\ Inetpub \\ vhosts \\ leojungen.com \\ httpdocs \\ launch-complaint.php上的'C:\\ Windows \\ Temp \\ php19A2.tmp'移動到'/images/24_silver_2_1.jpg' 72行

function uploadMultipleFiles($complaintId){
    global $_pdo;$path = '';
    // Count # of uploaded files in array
    $total = count($_FILES['files']['name']);
    // Loop through each file
    for($i=0; $i<$total; $i++) {
        //Get the temp file path
        $tmpFilePath = $_FILES['files']['tmp_name'][$i];
        //Make sure we have a filepath
        if ($tmpFilePath != ""){
            //Setup our new file path
            $newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
            //Upload the file into the temp dir
            //echo "path: "; print_r($_SERVER);exit;
            move_uploaded_file($tmpFilePath,$newFilePath);
        }
        $path .= $complaintId."_".$_FILES['files']['name'][$i]."^";
    }
}

在我的本地環境中,所有文件都在工作,但是當我實時部署它時,它就無法工作。

這是因為服務器上不存在目錄/images或缺少該目錄的write permission 檢查並解決此問題,然后重試。

$newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];

更改為

$newFilePath = "images/".$complaintId."_".$_FILES['files']['name'][$i];

而不是:$ newFilePath =“ /images/".$complaintId."_".$_FILES['files']['name'][$i];

請嘗試以下方法:

$ newFilePath =“ ./images".$complaintId."_".$_FILES['files']['name'][$i];

./images中的句點表示根/ images .....如果根目錄和images之間存在其他..包括它

我知道這是一個非常老的問題,但是我發布了這個答案,以便如果有像我這樣的newcoder出現,他會為我解決問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM