I have spent way too much time on this and browsed various questions/answers here on stackoverflow.
I am using dropzone.js to add a basic drag and drop upload feature to our HTML/PHP form. The drag and drop is working great however when the form is submitted or a file is uploaded the $_FILES returns empty and I cant figure it out.
I checked a tutorial and no luck, also checked some Q & A's from stackoverflow before posting here but nothing has helped.
Here is the form in its simplest form:
<form action="<? echo BASE_URL; ?>/process-uploads.php" method="POST" class="form-signin" role="form" enctype="multipart/form-data">
<div class="upload_container dropzone">Drag & drop file here or
<div class="fallback">
<input name="ad" type="file" />
</div>
</div><!--fileUpload btn btn-primary-->
<div class="dropzone-previews"></div>
<input class="btn btn-lg btn-primary btn-block btn-forward" style="background:#00a85a;" type="submit" name="submit" value="Next Step" />
</form>
The JS is:
<script type="text/javascript">
var myDropzone = new Dropzone(".dropzone", {
url: "<? echo BASE_URL; ?>/process-uploads.php/",
paramName: "ad",
addRemoveLinks: true,
//maxFiles: 1,
autoProcessQueue: false,
//uploadMultiple: false,
acceptedFiles: "image/png",
dictInvalidFileType: "This file type is not supported.",
});
</script>
And process-upload.php just checks to see if anything was sent, but returning empty:
<?php
if (!empty($_FILES)) {
echo 'We have a file';
if($_FILES['ad']) {
echo 'We grabbed the ad<br />';
echo '<pre>';
var_dump($_FILES);
echo '</pre>';
}
}
?>
Any help would be greatly appreciated. For reference I already checked enyo's tutorial for combining a form with dropzone and php