How to reset instance of AjaxUploader

Last post 02-28-2012, 5:19 AM by farinha. 4 replies.
Sort Posts: Previous Next
  •  02-17-2012, 12:08 PM 73054

    How to reset instance of AjaxUploader

    On the FileUploaded event I'm doing some validation (checking file type and whatnot), and in case there's an error, I want to completely dispose of the file that was uploaded. To achieve this I'm calling .ClearFile() and then returning from the event handler without further action.
    That doesn't seem to be enough, as I'm faced with 2 problems:
    1. The "filename (size)" text still appears in front of the upload Button. Since I want to make it clear the upload failed, I don't want this to show.
    2. After uploading a file that triggers the upload failure described, if I then upload a valid file, the uploader (sometimes) falls over. Basically the bit of code I have in place to hide the uploader and showing the file information doesn't get run because I end up with the file complete progress information.
    Is there something I'm missing in my "uploader reset"?
    Is there a way to achieve what I'm trying to do? 

    António Farinha
    http://antoniofarinha.com
    Filed under: , , ,
  •  02-20-2012, 3:59 AM 73078 in reply to 73054

    Re: How to reset instance of AjaxUploader

    Hi farinha,
     
    Can you create an example page which can reproduce both issues and post here? And show me the steps to reproduce it please. We will check it and get back to you as soon as possible.
     
    Regards,
     
    Ken 
  •  02-20-2012, 4:42 AM 73079 in reply to 73078

    Re: How to reset instance of AjaxUploader

    Hello,
     
    I just did as you suggested and created a sample web site to illustrate the problem, and managed to see an exception that gets thrown (in the original project it somehow is being gobbled up somewhere):
    The process cannot access the file 'C:\Users\farinhaa\AppData\Local\Temp\AjaxUploaderTemp\persisted.4e6a5843-f49c-4557-8b44-eab340cfe3ad.fake-image.gif.resx' because it is being used by another process.
    Here's a .zip with the website (not that I've omitted the .lic file). It also includes the files used to test:
     
    These are the steps taken to replicate:
    1. Upload fake-image.gif (this is a word .docx with its extension changed to .gif - used to test uploads of invalid images)
    2. After this upload a valid image. The Exception above is thrown
     
    It's also worth noting that uploading the other invalid image (fake-image-zero-bytes.jpg) also triggers the invalid image event, but uploading a valid image right after that doesn't cause the exception.
     
    The problem of the failed upload's image name showing up occurs every time. 

    António Farinha
    http://antoniofarinha.com
  •  02-21-2012, 7:26 AM 73106 in reply to 73079

    Re: How to reset instance of AjaxUploader

    Hi farinha,
     
    Your example works fine for me. And this issue should not cause by the invalid extension.
     
    You can try on http://www.ajaxuploader.com/Demo/select-multiple-files-upload.aspx  with your file. It works fine too.
     
    Regards,
     
    Ken 
  •  02-28-2012, 5:19 AM 73235 in reply to 73106

    Re: How to reset instance of AjaxUploader

    I sure can't replicate the issue in that demo page, but as you had the opportunity to see in my code sample, it's as barebones as it can get, and still I'm getting the Exception consistently.
    Can't exactly figure out what's happening, but it seems to have something to do with how the file is persisted. What's odd about it is I've only managed to get the Exception with that specific file, and it has worked fine with many others.
     
    Is there anything I can do to help track down this problem?

    António Farinha
    http://antoniofarinha.com
View as RSS news feed in XML