Advertisement
crazykid_ceh

Login Form Test

Jun 25th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>upload</title>
  6. </head>
  7. <body>
  8.  
  9. <?php
  10.  
  11. /**
  12. * @author CrazyKid Form CEH.vn
  13. * @copyright 2014
  14. */
  15.  
  16.  
  17. if ($_SERVER["REQUEST_METHOD"] == "POST")
  18.  
  19. {
  20.  
  21. $allowedExts = array("gif","jpeg","jpg","png");
  22. $temp = explode(".",$_FILES["file"]["name"]);
  23. $extension = end($temp);
  24. $NewNameFile = reset($temp)."_".rand(1,99999999).".".end($temp);
  25.  
  26.  
  27. if ((($_FILES["file"]["type"] == "image/gif")
  28. || ($_FILES["file"]["type"] == "image/jpeg")
  29. || ($_FILES["file"]["type"] == "image/jpg")
  30. || ($_FILES["file"]["type"] == "image/pjpeg")
  31. || ($_FILES["file"]["type"] == "image/x-png")
  32. || ($_FILES["file"]["type"] == "image/png"))
  33. && ($_FILES["file"]["size"] < 20000000) && in_array($extension,$allowedExts)) {
  34. if ($_FILES["file"]["error"] > 0) {
  35. echo "Error: " . $_FILES["file"]["error"] . "<br>";
  36. } else {
  37. echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  38. if (file_exists("upload/" . $_FILES["file"]["name"])) {
  39. echo $_FILES["file"]["name"] . "Already exists";
  40. } else {
  41. move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $NewNameFile);
  42. echo "File in upload/" . "<br>";
  43. echo "filename: ".$NewNameFile;
  44. }
  45. } } else {
  46. echo "Invalid file";
  47. }
  48. } else {
  49.  
  50. ?>
  51.  
  52. <form action="upload.php" method="POST" enctype="multipart/form-data">
  53. <label for="file">Filename: </label>
  54. <input type="file" name="file" id="file"><br>
  55. <input type="submit" name="submit" value="Submit">
  56. </form>
  57.  
  58. <?php } ?>
  59. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement