Hello,
I have created a drag and drop file uploader acctually downloaded from the internet I am trying to save the uploaded files to the database but it's unable to do so can anyone help me out or find a way for me to do so as the files are not moving to the folder neither saving into the database
upload.php
require_once("includes/connection.php");
if(isset($_FILES['files'])) {
$errors= array();
foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){
$file_name = $_FILES['files']['name'][$key];
$file_size = $_FILES['files']['size'][$key];
$file_tmp = $_FILES['files']['tmp_name'][$key];
$file_type = $_FILES['files']['type'][$key];
$upload_date = date("d-F-Y");
$query_get = mysqli_query($connection, "SELECT * FROM folderdata WHERE dataname='$file_name'");
$desired_dir = "./uploads";
move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
$dir_name = "http://localhost/comicsapp/admin/uploads/".$file_name;
$query = "INSERT into folderdata (`dataname`, `upload_date`) VALUES ('$file_name', '$upload_date')";
$confirm = mysqli_query($connection, $query);
if ($confirm) {
$_SESSION["message"] = "Menu updated successfully";
header("Location: ./index.php");
} else {
$_SESSION["message"] = "There was some errors please re-enter your information";
header("Location: ./index.php");
}
}
if(empty($error)){
echo "Success";
}
}
Here is my main index file
<?php
require_once("includes/connection.php");
?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>
Putti Forms
</title> <!-- CSS are placed here --> <link href="https://rawgithub.com/hayageek/jquery-upload-file/master/css/uploadfile.css" rel="stylesheet"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="https://rawgithub.com/hayageek/jquery-upload-file/master/js/jquery.uploadfile.min.js"></script> </head> <body> <div id="fileuploader">Upload</div> <script>
$(document).ready(function() {
$("#fileuploader").uploadFile({
url:"includes/upload.php",
fileName:"files"
});
});
</script> </body> </html>