Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
- <head>
- <!-- Add Dropzone -->
- <link rel="stylesheet" type="text/css" href="css/dropzone.css" />
- <script type="text/javascript" src="js/dropzone.js"></script>
- </head>
- <body>
- <h1>Drag&Drop Multiple Files Upload using DropzoneJS and PHP by CodexWorld</h1>
- <div class="image_upload_div">
- <form action="upload.php" class="dropzone">
- </form>
- <input type="text" name="text1">
- <input type="text" name="text2">
- </div>
- </body>
- </html>
- <?php
- if(!empty($_FILES)){
- //database configuration
- $dbHost = 'localhost';
- $dbUsername = 'root';
- $dbPassword = 'root';
- $dbName = 'sample';
- //connect with the database
- $conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
- if($mysqli->connect_errno){
- echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
- }
- $targetDir = "uploads/";
- $fileName = $_FILES['file']['name'];
- $targetFile = $targetDir.$fileName;
- if(move_uploaded_file($_FILES['file']['tmp_name'],$targetFile)){
- //insert file information into db table
- $conn->query("INSERT INTO files (file_name, uploaded) VALUES('".$fileName."','".date("Y-m-d H:i:s")."')");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement