Chrizz93

Untitled

Apr 25th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $database = "skp";
  6.  
  7. $conn = new mysqli($servername, $username, $password, $database);
  8.  
  9. if ($conn->connect_error) {    die("Connection failed: " . $conn->connect_error);
  10. }  mysqli_set_charset($conn, "utf8");
  11.  
  12. ?>
  13. <?php
  14. mysqli_query($conn,"SELECT * FROM upload");
  15. mysqli_query($conn,"INSERT INTO upload (name,type,size,content) VALUES ('".$_FILES['name']."')");
  16.  
  17. mysqli_close($conn);
  18.  
  19. $_FILES['submit']['name'];
  20. $_FILES['submit']['type'];
  21. $_FILES['submit']['size'];
  22. $_FILES['submit']['tmp_name'];
  23.  
  24. $uploaddir = "upload/";
  25. $uploadfile = $uploaddir . basename($_FILES["submit"]["name"]);
  26. $uploadOk = 1;
  27.  
  28. if (move_uploaded_file($_FILES['submit']['tmp_name'], $uploadfile)) {
  29.     echo "File is valid, and was successfully uploaded.\n";
  30. } else {
  31.     echo "Possible file upload attack!\n";
  32. }
  33.  
  34. echo 'Here is some more debugging info:';
  35. print_r($_FILES);
  36.  
  37. print "</pre>";
  38.  
  39.  
  40. if (file_exists($uploadfile)) {
  41.     echo "Sorry, file already exists.";
  42.     $uploadOk = 0;
  43. }
  44. if ($_FILES["upload"]["size"] > 500000) {
  45.     echo "Sorry, your file is too large.";
  46.     $uploadOk = 0;
  47. }
  48. if($FileType != "jpg" && $FileType != "png" && $FileType != "jpeg"
  49. && $FileType != "gif" && $FileType != "pdf") {
  50.     echo "Sorry, only JPG, JPEG, PNG, GIF and PDF files are allowed.";
  51.     $uploadOk = 0;
  52. }
  53.  
  54. if ($uploadOk == 0) {
  55.     echo "Sorry, your file was not uploaded.";
  56.  
  57. } else {
  58.     if (move_uploaded_file($_FILES["submit"]["tmp_name"], $target_file)) {
  59.         echo "The file ". basename( $_FILES["submit"]["name"]). " has been uploaded.";
  60.     } else {
  61.         echo "Sorry, there was an error uploading your file.";
  62.     }
  63. }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment