Heim > Fragen und Antworten > Hauptteil
<?phpif (count($_FILES)) { $retFiles = uploadFile("file"); if ($retFiles['status'] == 1) { echo $retFiles['message']; } else if ($retFiles['status'] == 0) { echo "Upload: " . $retFiles["name"] . "<br />"; echo "Typ: " . $retFiles["type"] . "<br />"; echo "Größe: " . ($retFiles["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $retFiles["temp"] . "<br />"; echo "Gespeichert in: " . "hochladen/" . $retFiles["name"]; }}function uploadFile($fileName){ $files = $_FILES[$fileName]; if (!in_array($files["type"], array("image/gif", "image/jpeg", "image/pjpeg", "image/jpeg", "image/png"))) { Array zurückgeben ("status" => 1, "message" => "Das hochgeladene Bildformat ist nicht korrekt"); } if ($files["error"] > 0) { return array("status" => 1, "message" => "upload error"); } if (file_exists("upload/" . $files["name"])) { return array("status" => 1, "message" => $files["name"]." bereits vorhanden") ; } 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"]);}?>就是这段代码