Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  3. <head>
  4. <!-- Add Dropzone -->
  5. <link rel="stylesheet" type="text/css" href="css/dropzone.css" />
  6. <script type="text/javascript" src="js/dropzone.js"></script>
  7. </head>
  8. <body>
  9. <h1>Drag&Drop Multiple Files Upload using DropzoneJS and PHP by CodexWorld</h1>
  10. <div class="image_upload_div">
  11. <form action="upload.php" class="dropzone">
  12. </form>
  13. <input type="text" name="text1">
  14. <input type="text" name="text2">
  15. </div>
  16. </body>
  17. </html>
  18.  
  19. <?php
  20. if(!empty($_FILES)){
  21.  
  22. //database configuration
  23. $dbHost = 'localhost';
  24. $dbUsername = 'root';
  25. $dbPassword = 'root';
  26. $dbName = 'sample';
  27. //connect with the database
  28. $conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
  29. if($mysqli->connect_errno){
  30. echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  31. }
  32.  
  33. $targetDir = "uploads/";
  34. $fileName = $_FILES['file']['name'];
  35. $targetFile = $targetDir.$fileName;
  36. if(move_uploaded_file($_FILES['file']['tmp_name'],$targetFile)){
  37. //insert file information into db table
  38. $conn->query("INSERT INTO files (file_name, uploaded) VALUES('".$fileName."','".date("Y-m-d H:i:s")."')");
  39. }
  40.  
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement