Rumah > Soal Jawab > teks badan
<?phpif (count($_FILES)) { $retFiles = uploadFile("file"); if ($retFiles['status'] == 1) { echo $retFiles['message']; } else if ($retFiles['status'] == 0) { echo "Muat naik: " . $retFiles["nama"] . "<br />"; echo "Jenis: " . $retFiles["type"] . "<br />"; echo "Saiz: " . ($retFiles["saiz"] / 1024) . " Kb<br />"; echo "Fail temp: " . $retFiles["temp"] . "<br />"; echo "Disimpan dalam: " . "muat naik/" . $retFiles["nama"]; }}function uploadFile($fileName){ $files = $_FILES[$fileName]; if (!in_array($files["type"], array("image/gif","image/jpeg","image/pjpeg","image/jpeg", "image/png"))) { return array ("status" => 1, "message" => "Format imej yang dimuat naik tidak betul"); } jika ($files["error"] > 0) { return array("status" => 1, "message" => "ralat muat naik"); } if (file_exists("upload/" . $files["name"])) { return array("status" => 1, "message" => $files["name"]." already exists") ; } move_uploaded_file($files["tmp_name"], "upload/".$files["name"]); return array("status" => 0, "name" => $files["name"], "type" => $files["type"], "size" => $files['size ']/1024, "temp" => $files["tmp_name"]);}?>就是这段代码
A峰2019-12-02 18:07:32
Tetapkan pengekodan aksara dan lihat: header("Content-type:text/html;charset=utf-8");