$date = date(ymdhis); //echo($date); if ((($_FILES["uppic"]["type"] == "image/gif") || ($_FILES["uppic"]["type"] == "image/jpeg") || ($_FILES["uppic"]["type"] == "image/pjpeg")) && ($_FILES["uppic"]["size"] { if ($_FILES["uppic"]["error"] > 0) { echo "Return Code: " . $_FILES["uppic"]["error"] . " "; } else { //echo "Upload: " . $_FILES["uppic"]["name"] . " "; //echo "Type: " . $_FILES["uppic"]["type"] . " "; //echo "Size: " . ($_FILES["uppic"]["size"] / 1024) . " Kb "; //echo "Temp file: " . $_FILES["uppic"]["tmp_name"] . " "; $uptype = explode(".", $_FILES["uppic"]["name"]); $newname = $date.".".$uptype[1]; //echo($newname); $_FILES["uppic"]["name"] = $newname;
if (file_exists("pics/" . $_FILES["uppic"]["name"])) { echo $_FILES["uppic"]["name"] . " already exists. "; } else { $_FILES["uppic"]["name"] = move_uploaded_file($_FILES["uppic"]["tmp_name"], "pics/" . $_FILES["uppic"]["name"]); echo "<script>alert('上传成功!')</script>"; echo "<script>window.location.href='http://www.phprm.com';</script>"; } } } else { echo "Invalid file"; } ?>
|