Stopping duplicate files

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Stopping duplicate files

Bryan
I want to stop the user from adding the same file twice.  So, I modified the onchange handler for the input file like so:

        GetInputFileElem().onchange = function(ev) {
            if (IsDupeFile(this.value)) {
                alert("'" + this.value + "' has already been added");
                return false;
            }
            ...existing code here...
        }

I did this in order to make sure that the file was not added to the FileToUpload array, and also to keep it from cloning a new input file control.  This seems to work fine.  If the users selects a file, it shows up on the page, then if they try to select the same file again, they get the alert and no new file shows up on the page.

However, once the form is submitted, my multiFile control still has 2 files when I check in my server side handler for the form submit.  What's up with that?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping duplicate files

Dean Brettle
Administrator
See <a href="http://www.brettle.com/NeatUpload-1.3/dotnet/docs/Manual.html#5.5.Customizing%20MultiFile%27s%20Handling%20of%20Queued%20Files|outline">Customizing MultiFile's Handling of Queued Files.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping duplicate files

Bryan
I had already read that section.  I already have a heavily modified OnFileQueued section.  However, the reason I went with trying to put the dupe check in the event handler was because by the time OnFileQueued is called, the file is already in the FilesToUpload array.  I wanted to try to catch it BEFORE it was put in the array.  However, my attempt fails, as described in my original post.

So, I moved my dupe check to OnFileQueued instead, and everything seems to work fine now.  Sorry to bother you.  :-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping duplicate files

Dean Brettle
Administrator
On Thu, Apr 29, 2010 at 2:05 PM, Bryan [via Support Forums] <[hidden email]> wrote:
I had already read that section.  I already have a heavily modified OnFileQueued section.  However, the reason I went with trying to put the dupe check in the event handler was because by the time OnFileQueued is called, the file is already in the FilesToUpload array.  I wanted to try to catch it BEFORE it was put in the array.  However, my attempt fails, as described in my original post.

So, I moved my dupe check to OnFileQueued instead, and everything seems to work fine now.  Sorry to bother you.  :-)

Yeah.  I was suggesting putting the dupe check in OnFileQueued() and then Delete()ing the dupe there.  Sounds like that's what you did.

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping duplicate files

Bryan
Did you mean to put something in that reply?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping duplicate files

Dean Brettle
Administrator
Sorry.  Nabble bug.  It should have said:

 
Bryan wrote
I had already read that section.  I already have a heavily modified OnFileQueued section.  However, the reason I went with trying to put the dupe check in the event handler was because by the time OnFileQueued is called, the file is already in the FilesToUpload array.  I wanted to try to catch it BEFORE it was put in the array.  However, my attempt fails, as described in my original post.

    So, I moved my dupe check to OnFileQueued instead, and everything seems to work fine now.  Sorry to bother you.  :-)
Yeah.  I was suggesting putting the dupe check in OnFileQueued() and then Delete()ing the dupe there.  Sounds like that's what you did.
Loading...