Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>upload</title>
- </head>
- <body>
- <?php
- /**
- * @author CrazyKid Form CEH.vn
- * @copyright 2014
- */
- if ($_SERVER["REQUEST_METHOD"] == "POST")
- {
- $allowedExts = array("gif","jpeg","jpg","png");
- $temp = explode(".",$_FILES["file"]["name"]);
- $extension = end($temp);
- $NewNameFile = reset($temp)."_".rand(1,99999999).".".end($temp);
- if ((($_FILES["file"]["type"] == "image/gif")
- || ($_FILES["file"]["type"] == "image/jpeg")
- || ($_FILES["file"]["type"] == "image/jpg")
- || ($_FILES["file"]["type"] == "image/pjpeg")
- || ($_FILES["file"]["type"] == "image/x-png")
- || ($_FILES["file"]["type"] == "image/png"))
- && ($_FILES["file"]["size"] < 20000000) && in_array($extension,$allowedExts)) {
- if ($_FILES["file"]["error"] > 0) {
- echo "Error: " . $_FILES["file"]["error"] . "<br>";
- } else {
- echo "Upload: " . $_FILES["file"]["name"] . "<br>";
- if (file_exists("upload/" . $_FILES["file"]["name"])) {
- echo $_FILES["file"]["name"] . "Already exists";
- } else {
- move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $NewNameFile);
- echo "File in upload/" . "<br>";
- echo "filename: ".$NewNameFile;
- }
- } } else {
- echo "Invalid file";
- }
- } else {
- ?>
- <form action="upload.php" method="POST" enctype="multipart/form-data">
- <label for="file">Filename: </label>
- <input type="file" name="file" id="file"><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php } ?>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement