Reputation: 41
Hello I am having a problem using the custom options in Dropzone.js. It is not displaying the remove links even when I set it to true. I am not sure if I am going about this wrong or what exactly is happening. The files are uploading correctly and the loading bar & completed check mark show.
The current code I have is:
<html>
<head>
<!-- 1 -->
<link href="models/site-templates/dropzone.css" type="text/css" rel="stylesheet" />
<!-- 2 -->
<script src="models/dropzone.js">
Dropzone.options.myDropzone = {
addRemoveLinks: true,
};
</script>
</head>
<body>
<!-- 3 -->
<form id="myDropzone" action="upload.php" class="dropzone"></form>
</body>
</html>
Here's upload.php
<?php
$ds = "/"; //1
$storeFolder = 'uploads'; //2
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name']; //3
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds . "temp" . $ds; //4
$targetFile = $targetPath. $_FILES['file']['name']; //5
move_uploaded_file($tempFile,$targetFile); //6
}
?>
Upvotes: 4
Views: 11339
Reputation: 3752
Declare you dropzone initialization in its own separate script element and to remove the thumbnail add a removedFile method:-
<script src="./lib/dropzone-3.12/dropzone.js"></script>
<script type="text/javascript">
Dropzone.options.myDropzone = {
addRemoveLinks: true,
removedfile: function(file) {
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
};
</script>
Upvotes: 4