javascript - Dropzone Js not uploading my files [Code Igniter]
Get the solution ↓↓↓I was trying to upload files with using dropzone js, howewer it doesn't work I have the "upload complete animation with the progress bar" but there is not files uploaded in my uploads folder.
View :
<body>
<div id="content">
<form method="post" action="<?php echo base_url() ?>images/upload" enctype="multipart/form-data" class="dropzone" id="myAwesomeDropzone">
</form>
<button type="button" id="submit_dropzone_form">UPLOAD</button>
</div>
<script src="<?php echo base_url(); ?>vendor/jquery/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>vendor/dropzone/dropzone.min.js"></script>
<script>
Dropzone.options.myAwesomeDropzone = {
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads:10,
url: "<?php echo site_url("images/upload") ?>",
successmultiple:function(data,response){
$("#uploaded_files").val(response);
},
init: function() {
//Submitting the form on button click
var submitButton = document.querySelector("#submit_dropzone_form");
myDropzone = this; // closure
submitButton.addEventListener("click", function() {
myDropzone.processQueue(); // Tell Dropzone to process all queued files.
});
}
};
</script>
</body>
Controller :
public function upload()
{
if ( ! empty($_FILES))
{
$config["upload_path"] = $this->upload_path;
$config["allowed_types"] = "application/pdf";
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload("file")) {
echo "failed to upload file(s)";
}
}
}
where $upload_path = "./uploads"
As you can see I have a folder in my CI root project.
Answer
Solution:
Well, I solved my issue I think that the allowed types was wrong or the upload path wasn't the good one.
With this method in my controller, it work.
public function upload()
{
if ( ! empty($_FILES))
{
$config["upload_path"] = $this->upload_path;
$config["allowed_types"] = "pdf";
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload("file")) {
echo "failed to upload file(s)";
}
}
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: integrity constraint violation: 1452 cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.