Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It doesn't delete file when clicking Delete photo #18

Open
Sabirgojayev opened this issue Mar 13, 2017 · 1 comment
Open

It doesn't delete file when clicking Delete photo #18

Sabirgojayev opened this issue Mar 13, 2017 · 1 comment

Comments

@Sabirgojayev
Copy link

It doesn't delete file when clicking Delete photo but only image from preview. How can I make it delete cropped image file.

@Sabirgojayev
Copy link
Author

I send ajax request in cropper.js on click event and delete image may be it will be useful for someone:
.on('click', '.delete-photo', function () {
$.ajax({
method: "POST",
url: '/admin/news/deletephoto',
dataType: "html",
data: {crop : cropper.$thumbnail.attr('src')},
success: function(html){
alert(html);
}
});
cropper.deletePhoto();
})
example of implementation on server side:
if(Yii::$app->request->isAjax) {
$img = $_SERVER['DOCUMENT_ROOT'].$_POST['crop'];
if(file_exists($img)) {
unlink($img);
return "Şəkil müvəfəqiyyətlə silindi";
}
else return "Belə bir şəkil yoxdur";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant