wenhongquan / ocupload

Automatically exported from code.google.com/p/ocupload
0 stars 0 forks source link

Uploading the same file Twice : Second time not uploading #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. click on the upload link
2. upload a file
3. try to upload the file with the same name ,by clicking the link again

What is the expected output? What do you see instead?
it should upload the file again

What version of the product are you using? On what operating system?
jquery-1.2.6.js and jquery.ocupload-1.1.2.js

Please provide any additional information below.

If I Try to upload the file twice, it will not get uploaded for the second
time.  

Original issue reported on code.google.com by avsrit2...@gmail.com on 11 Nov 2008 at 9:12

GoogleCodeExporter commented 9 years ago
I think this is related to the input tag being checked for changes. Probably
recreating the input would work, since that would clear the input's value. Not 
sure
if values can be cleared in file inputs though.

Original comment by krof.drakula on 18 Nov 2008 at 12:51

GoogleCodeExporter commented 9 years ago
I had this problem too.  I fixed it in the following way - it's not perfect but 
it
got the job done for me.

I added a name and an id to the form that gets created on the fly that submits 
to the
iframe.  Then, in my onComplete callback, I reset the form.  That's the only 
way I
could find to easily null out the value in the input file element.

Original comment by lizzsomm...@gmail.com on 18 Nov 2008 at 5:31

GoogleCodeExporter commented 9 years ago

Original comment by mhorn...@gmail.com on 18 Dec 2008 at 4:26

GoogleCodeExporter commented 9 years ago
You can fix this by clearing out the input field in the onComplete handler.

$("input[@name='video']").val("");

Where 'video' is the name assigned in the upload method.

Original comment by mmjohns...@gmail.com on 16 Jan 2009 at 7:19

GoogleCodeExporter commented 9 years ago
Hi there!
I'm using this very usefull plugin (thx btw) but unfortunately i'm facing the 
same 
issue described below (second time not uploading). I spent the last 2 days 
various 
methods (including "mmjohns314" one) without success ;-(
All I succeed to do is to make it work fine with IE (using form.reset) but no 
way 
with FF and Chrome.
Any help will be greatly appreciated.

Thanks,
YB

Original comment by ybenam...@gmail.com on 25 Jan 2009 at 6:03

GoogleCodeExporter commented 9 years ago
2 ybenammou,
onComplete: function() { $("form[target^='iframe']")[0].reset(); }

Original comment by Slava0...@gmail.com on 12 Aug 2009 at 10:48

GoogleCodeExporter commented 9 years ago
Slava0008
Ogromnoe tebe spasibo i zdorovya ya ubil 3 chsa ne smog dognat :)
from amastudio.ru

Original comment by amasm...@gmail.com on 6 Nov 2009 at 7:13

GoogleCodeExporter commented 9 years ago
You can also add this simple javascript instruction :
document.forms['form_id'].reset() in the onComplete handler event. 

Original comment by fsandr...@gmail.com on 26 Nov 2009 at 5:25

GoogleCodeExporter commented 9 years ago
Instead of resetting the entire form, which is a pain, I've changed the script 
a little bit so that it support multiple file uploads. Basically you need to 
*recreate* the input element in order to "clear" it. In many browsers you 
cannot set the value of a file input element to "", or to anything for that 
matter, as that's a security risk. However some browsers do support that (eg. 
Firefox) but they should not!

Check out the attached modified script. You will notice I created a private 
function which sets up a *new* input element. This is called once when you 
first set it up of course.

There is a public method called "resetInput" which calls that function, 
essentially re-creating the file input element. This is what you need to after 
uploading each file. eg. $myocupload.resetInput()

I've done some other useful things to the script as well, to help when making a 
dynamic list of files you can add to (which is what I was trying to do). The 
events onSelect, onSubmit and onComplete now passes "self" (the ocupload 
instance) and "element" (the button you applied it to). This way you don't need 
to have a "$myocupload" variable at all. They come across in the event calls.

There is also a $input() method, which returns the file input element being 
used. So, to support a multi-upload list, you basically do two things:
1. Get $input() and append it to your form,
2. Call resetInput() to make ocupload create a new file input element to 
replace it.

Tested in Firefox, IE6, IE8 and Chrome. Working very well for me. :) Hope it 
helps some else. I think this is still a very useful plugin and should be 
developed further.

Original comment by lectroid...@yahoo.com.au on 10 Jul 2011 at 3:12

Attachments:

GoogleCodeExporter commented 9 years ago
This is my fix, 

1.

var form = $(
            '<form ' +
                'method="post" ' +
                'enctype="' + options.enctype + '" ' +
                'action="' + options.action + '" ' +
                'target="iframe' + id + '"' +
                'id="form_'+ id +'"' +
            '></form>'

after submit clear values:

form.submit()

          current_form = document.getElementById('form_' + id)

          while ( current_form.firstChild ) {
            current_form.removeChild( current_form.firstChild )
          }
          this.resetInput()

Original comment by p.ela...@gmail.com on 4 Mar 2012 at 10:09

Attachments:

GoogleCodeExporter commented 9 years ago
Simple fix

ocupload-1.1.2.js

form.submit();  //Line 127

input.attr('value',''); //Added this line to reset the value

Original comment by marum.g...@gmail.com on 20 Jun 2012 at 2:13