I have a PHP picture upload form, so user can send one picture and in next step he can crop this image and some other functions.
My problem is, the user can send many pictures without finished the process so this pictures will be stored in my server and will have no utility.
So I think to solve it using ajax, show an alert when user try to close/leave the page asking if he is sure about this and if he is, call an ajax to delete the image.
I found a function using javascript, but I need one using JQUERY to be able to use AJAX to delete the picture:
function setConfirmUnload(on) {
window.onbeforeunload = (on) ? unloadMessage : null;
}
function unloadMessage() {
return "Are you sure you want to leave this page";
}
is it a good idea? how can I solve this? Any jquery examples or php ideas to avoid storing unecessary uploaded images on my server?