dropify icon indicating copy to clipboard operation
dropify copied to clipboard

Getting a value if user either remove or going with the default value

Open imam opened this issue 8 years ago • 4 comments

The use case is:

  • If I click remove button, it's should send null in the request (So I know the user don't want to send a new picture, and they want to remove the current existing photo in the server)
  • If I don't click the remove button, it should send back to the default file value (So I know the user don't want to send a new picture, neither removing the existing one that already on the server).

Is this use case built in already?

imam avatar Mar 31 '17 07:03 imam

Both cases, same output(null)

imam avatar Mar 31 '17 08:03 imam

+1 with the same issue.

str avatar Apr 06 '17 00:04 str

As a temporary workaround you could use additional hidden input like this, gets the job done:

<input type="file" name="picture" class="dropify" data-default-file="file.jpg">
<input type="hidden" name="picture_removed" id="picture_removed" value="0">

And use js callback:

var drEvent = $('.dropify').dropify();
drEvent.on('dropify.afterClear', function(event, element){
$("#picture_removed").val("1");
});

And finally check in your php:

if($_POST['picture_removed'] == 1) {
unlink('file.jpg');
}

ernexus avatar Nov 07 '19 12:11 ernexus

did you get the answer

AhmedELGAMMUDI avatar Jul 28 '20 11:07 AhmedELGAMMUDI