Click here to Skip to main content
15,845,785 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to configure dropzone for removing images, I've done `addRemoveLinks: true` i want the php code to delete that file? How can I get the id of the file to delete? And my second question is how can I upload videos through dropzone? And the third question is how can I restrict size of the files in dropzone?

What I have tried:

if(typeof Dropzone != 'undefined')
	Dropzone.autoDiscover = false;
	var myDropzone = new Dropzone("#myDropzone", {
		url: "data/upload-file.php",
		maxFileSize: 50,
		acceptedFiles: ".pdf",
		addRemoveLinks: true,
		removedfile: function(file){
			var name =;
				type: 'POST',
				url: 'delete.php',
				data: "id="+name,
				dataType: 'html'
			var _ref;
			return(_ref = file.previewElement) != null
				? _ref.parentNode.removeChild(file.previewElement)
				: void 0;

and this is delete.php:
	$$dbHost = 'localhost';
	$dbUsername = 'root';
	$dbPassword = '';
	$dbName = 'newimg';

	//connect with the database
	$conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);

		echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

	$upload_dir = 'uploads';
	$targetPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $upload_dir . DIRECTORY_SEPARATOR;

	$obj=new DB();
	$sql = "DELETE FROM files WHERE id='".$_GET['id']."'";
	$retval = mysqli_query($obj->connection(),$sql);

	print_r("Successfully deleted.");
Updated 26-Aug-17 22:25pm
Graeme_Grant 27-Aug-17 3:26am    
Formatting is important. Fixed for you.
Member 13074487 27-Aug-17 3:34am    
thank you.. but it's still not working..

I recommend you look at the following links.

javascript - how to add removefile option in dropzone plugin? - Stack Overflow[^]

Upload Delete from server MySQL, uploaded file in Dropzone.js using PHP[^]

javascript - how to upload and delete files from dropzone.js - Stack Overflow[^]

delete files in dropzone.js using php - Google Search[^]

Now after you review the following links, if you want to come back with more information on what you have tried and a clear explanation of the issue you face feel free, also provide some samples of the code you are attempting to rig up with dropzone.
Share this answer
Member 13074487 27-Aug-17 2:27am    
I've posted it @Graeme_Grant
Graeme_Grant 27-Aug-17 3:03am    
If you're going to post code and want people to review it, posting it as a reply is the quickest way to not get a response. Instead, click on the "Improve question" widget, post the code in the "What I have tried:" section and explain what is not working and any error message(s) that you seeing.
The information that you seek is on this page: Dropzone.js[^].

When you navigate to the page and it is loaded, use the web browser find function (CTRL-F) and search for "Remove". Step through the results and you will find what you are looking for.

For example:
If you want to remove an added file from the dropzone, you can call .removeFile(file). This method also triggers the removedfile event.

And the followinbg sample code:
myDropzone.on("complete", function(file) {
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900