Results 1 to 5 of 5

Thread: Upload the same file

  1. #1
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default Upload the same file

    You cannot select and upload the same file except in Firefox, which mistakenly allows you to do so:

    Code:
    <input type="file" id="fileChooser">
    document.getElementById('fileChooser').onchange = function () {
        alert('Uploaded!');
    };
    Here's my approach to resolve the issue. I wonder if there's a neater way to achieve it.
    Last edited by Rain Lover; 06-08-2014 at 09:45 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't get it:

    1. I thought file inputs were off limits to javascript.

    2. Even if this fires onchange, then wouldn't it be a different file?


    Server side code used to process the upload would be a better place to weed out duplicates, right?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by jscheuer1 View Post
    I thought file inputs were off limits to javascript.
    Thanks to HTML5 File API now we can even read a file content with JavaScript: demo.


    I don't get it
    Sorry if the question isn't very clear!
    I mean you cannot re-select the same file twice in a row, i.e. you select and upload foo.txt on your desktop, for example, and then click the file chooser again, file select dialog appears and you try to select the same file again -- the browser simply does nothing and no alert box appears.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, obviously I haven't been messing around with this much lately. Perhaps the rules have changed. Anyways, if that works, then it's fine. Does it?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by jscheuer1 View Post
    Anyways, if that works, then it's fine. Does it?
    Yes, it seems to be working with no problem.
    Thanks, anyway!

Similar Threads

  1. Replies: 1
    Last Post: 11-03-2008, 08:16 PM
  2. how can i do file upload control to upload any image
    By Rai_87 in forum MySQL and other databases
    Replies: 0
    Last Post: 07-04-2008, 01:36 AM
  3. file upload
    By syazyan in forum PHP
    Replies: 0
    Last Post: 11-23-2006, 08:00 AM
  4. Upload a file
    By adriana_l_2000 in forum PHP
    Replies: 3
    Last Post: 11-25-2005, 04:50 PM
  5. file upload or file attach
    By xeno in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-03-2005, 11:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •