第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

is_uploaded_file 函數(shù)在 linux 中有效,但在 Windows 中無效

is_uploaded_file 函數(shù)在 linux 中有效,但在 Windows 中無效

PHP
元芳怎么了 2022-07-02 16:24:00
代碼if(is_array($_FILES) && isset($_FILES['photography_attachment'])) {      if(is_uploaded_file($_FILES['photography_attachment']['tmp_name'])) {        $fileName = $_FILES["photography_attachment"]["name"]; // The file name        $fileTmpLoc = $_FILES["photography_attachment"]["tmp_name"]; // File in the PHP tmp folder        $fileType = $_FILES["photography_attachment"]["type"]; // The type of file it is        $fileSize = $_FILES["photography_attachment"]["size"]; // File size in bytes        $fileErrorMsg = $_FILES["photography_attachment"]["error"]; // 0 = false | 1 = true        $kaboom = explode(".", $fileName); // Split file name into an array using the dot        $fileExt = end($kaboom); // Now target the last array element to get the file extension        if (!$fileTmpLoc) { // if file not chosen          $error = $error."<p>Please browse for a file before clicking the upload button.</p>";        } else if($fileSize > 10485760) { // if file size is larger than 2 Megabytes          $error = $error."<p><span>Your file was larger than</span> 10 <span>Megabytes in size</span>.</p>";          unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder        } else if (!preg_match("/.(gif|jpg|png|jpeg)$/i", $fileName) ) {          // This condition is only if you wish to allow uploading of specific file types          $error = $error."<p>Your file was not .gif, .jpg, .png</p>";          unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder        } else if ($fileErrorMsg == 1) { // if file upload error key is equal to 1          $error = $error."<p>An error occured while processing the file. Try again.</p>";        }     }else{ $error = "Please try again !!!"; }  }else{ $error = "Attachment field cannot be blank!"; }總是轉(zhuǎn)到“請再試一次!?。 ?否則在 Windows 中上傳圖像時,但在 linux 系統(tǒng)中運行良好。你能請任何人幫我解決這個問題嗎?
查看完整描述

1 回答

?
慕少森

TA貢獻2019條經(jīng)驗 獲得超9個贊

在 Windows 平臺上,您必須將文件路徑中的“\”替換為“/”


像這樣:


$file = str_replace ("\\", "/", $_FILES['photography_attachment']['tmp_name']);

if(is_uploaded_file($file)) {

   [...]

}

或者對所有系統(tǒng)使用 php build in 方法:


$file = realpath($_FILES['photography_attachment']['tmp_name']);

if(is_uploaded_file($file)) {

   [...]

}


查看完整回答
反對 回復(fù) 2022-07-02
  • 1 回答
  • 0 關(guān)注
  • 112 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號