Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Cancel file uploaded
  • Hello

    I wonder if it was possible to delete the downloaded file by clicking the cancel button of the list.

    If so how can I do?

    thank you.

    ps: Sorry for mistakes I'm french dishes :D
  • i have same question. who can help us?
    tks.
  • Handle the onCancel and call a server script using ajax to delete file if exists
  • you can add a hidden input to store file informations on the complete event, so you can use ajax, when you delete it:


    'onComplete' : function(event, ID, fileObj, response, data) {
    var filename = fileObj.name;
    $('#myform').append('<input id="' + ID + '" type="hidden" name="files[' + ID + ']" value="' + filename +'" />');
    },
    'onCancel' : function(event,ID,fileObj,data) {
    var filename = $('#' + ID).val();
    $.ajax({
    type: "GET",
    url: "ajax.php",
    data: "ajaxmode=uploadify_removefile&file=" + filename
    });
    $('#' + ID).remove();
    }


    and in the ajax.php you can unlink, delete the file.
  • lolka_bolka your thread seems to be very useful. But I am not good at ajax at all. Could you please tell me how ajax.php file will look like according to the codes you give on your thread?



    Many thanks
  • Very basic, but this is the gist of what you need:

    <?php

    switch ($_REQUEST['ajaxmode']) {
    case "uploadify_removefile":
    $fileToDelete = $_SERVER['DOCUMENT_ROOT'] . "/folder_you_upload_to/" . $_REQUEST['file'];
    while(is_file($fileToDelete) == TRUE)
    {
    chmod($fileToDelete, 0666);
    unlink($fileToDelete);
    }
    break;
    }
    ?>