I have absolutely no idea why what I did has resolved this issue, but I'll
post what I did because perhaps it will help someone that will face the same
problem.
I was creating my input files dynamically, using document.createElement().
after create them, I put them in a div, and after render the div, I pass the
inputs to the method FileSubbmiter.captureFile() one by one, to capture the
files. It didn't work on I.E, only in firefox, so, after lots of tests,
comes to me a divine light and even with no reason, I stopped of creating
inputs by document.createElement and just wrote the HTML code on innerHTML
property of the div that I was rendering the inputs. Now everything is fine
in I.E and also in Firefox. bellow I'll show, first the code of creation of
inputs that doesn't work and after the code that works:
1 - doesn't work:
divFile = document.createElement('DIV');
var inputFile = document.createElement("INPUT");
inputFile.id = "inputFile_"+id_border+"_"+countDivFiles;
inputFile.type = 'file';
inputFile.name='file_'+countDivFiles;
divFile.appendChild(inputFile);
2 - works:
divFile = document.createElement('DIV');
divFile.innerHTML = "<input type='file'
id='"+"inputFile_"+id_border+"_"+countDivFiles+"'
name='file_"+countDivFiles+"'>";
as I said, I don't know why the captureFile in I.E doesn't work when I pass
the input file created by the first step, but, it doesn't.
2009/5/7 Diogenes Duarte <[email protected]>
> what you've assumed was almost everything correct, except the id_queue
> observation. I use it, but I've just removed the code for we can focus on
> the problem.
>
> to debug, following your trips, I did this:
>
> in line this.store.captureFile(tmp_input, url_local); I changed to
> this.store.captureFile(document.getElementById(tmp_input.id), url_local);.
> I've also put an alert to see what comes in tmp_input.id and it showed the
> correct Id of the input. Nothing new happened
>
> Thinking about d.getTime(), I changed the url_name to a simple string and
> nothing has changed. The result keeps being an alert with the message object
> error.
>
> I also thought that the error was in I.E, or in my implementation, but as
> much as I make tests, more I think it's a gears' bug. Do you have any other
> suggestion to test?
>
> 2009/5/7 Eduard Martini <[email protected]>
>
>
>> In this code:
>>
>> local_messages.prototype.send_attach_to_queue = function
>> (id_queue,form) {
>> for(i=0;i<form.elements.length;i++) {
>> if(form.elements[i].name.indexOf("file_")!=-1) {
>> var tmp_input = form.elements[i];
>>
>> var d = new Date();
>> var url_local = 'local_attachs/'+d.getTime();
>> *this.store.captureFile(tmp_input, url_local);*
>> }
>> }
>> }
>>
>> I assume that:
>>
>> 1. form is a dom element something like form = getElementById
>> (html_id_of_the_form_element)
>> 2. code of this function is not complete because id_queue is not used
>> in this function
>> 3. you have a form with many <input type="file"... elements and you
>> iterate across them and capture all files. If this is not the case and
>> you have only one file element, do directlu tmp_input = getElementById
>> (html_id_of_the_FILE_element);
>>
>> What I would do to debug this problem:
>>
>> 1. First I do not think this is a gears problem, I think this is an IE
>> problem
>> 2. I would remove all other code and test with a basic setup:
>> Let only one file element in form, put an id on it and do something
>> like:
>>
>> local_messages.prototype.send_attach_to_queue = function
>> (id_queue,form) {
>>
>> tmp_input = getElementById
>> (html_id_of_the_FILE_element);
>> var url_local = 'local_attachs/'test_file;
>> this.store.captureFile(tmp_input, url_local);
>> }
>> }
>> }
>>
>> 3. If this works, I would put back the the code, but using i as
>> dynamic url:
>>
>>
>> local_messages.prototype.send_attach_to_queue = function
>> (id_queue,form) {
>> for(i=0;i<form.elements.length;i++) {
>> if(form.elements[i].name.indexOf("file_")!=-1) {
>> var tmp_input = form.elements[i];
>> var url_local = 'local_attachs/'+i;
>> *this.store.captureFile(tmp_input, url_local);*
>> }
>> }
>> }
>>
>> 4. if this still works, means the getTime() is the problem. As I know
>> getTime() function can return object on IE on some cases instead of
>> float.
>>
>> Hope this helps
>>
>>
>> Please correct me if any of my assumption are incorrect.
>>
>> On May 6, 4:54 pm, Diogenes Duarte <[email protected]> wrote:
>> > sorry, I forgot to say that I call init_local_messages before I call
>> > send_attach_to_queue.
>> >
>> > 2009/5/6 Diogenes Duarte <[email protected]>
>> >
>> > > I can show you the code...
>> >
>> > > function local_messages() {
>> > > this.dbGears = null;
>> > > this.localServer = null;
>> > > this.store = null;
>> > > }
>> >
>> > > local_messages.prototype.init_local_messages = function(){
>> > > if(this.dbGears == null)
>> > > this.dbGears =
>> google.gears.factory.create('beta.database');
>> > > if(this.localServer==null)
>> > > this.localServer =
>> > > google.gears.factory.create('beta.localserver');
>> > > if(this.store==null)
>> > > this.store = this.localServer.createStore('test-store');
>> > > }
>> >
>> > > local_messages.prototype.send_attach_to_queue =
>> function(id_queue,form) {
>> > > for(i=0;i<form.elements.length;i++) {
>> > > if(form.elements[i].name.indexOf("file_")!=-1) {
>> > > var tmp_input = form.elements[i];
>> >
>> > > var d = new Date();
>> > > var url_local = 'local_attachs/'+d.getTime();
>> > > *this.store.captureFile(tmp_input, url_local);*
>> > > }
>> > > }
>> > > }
>> >
>> > > After bold line, on I.E, the app shows an alert with the message:
>> "object
>> > > error". In firefox it works perfectly. I can't imagine why this is
>> > > happening... does anyone can see why?
>> >
>> > > I know the method is deprecated, but I can't change all my code to
>> change
>> > > deprecated methods. at least, not now. we have plans for doing that in
>> 2 or
>> > > 3 months, but, for now I really need the methods doing what they say
>> they
>> > > do, even the deprecateds.
>> >
>> > > thanks for attention.
>> >
>> > > 2009/5/5 carise <[email protected]>
>> >
>> > >> Hi,
>> >
>> > >> Can you provide your code (especially the javascript)?
>> >
>> > >> On May 5, 6:10 am, Diogenes Duarte <[email protected]>
>> wrote:
>> > >> > I have an app using captureFile method and it's working fine on
>> firefox,
>> > >> but
>> > >> > crashes in I.E. It's the same code in both browsers, and in I.E
>> shows an
>> > >> > alert that says: "Object Error". In the end, the function doesn't
>> work.
>> >
>> > >> > Any idea why this is happening?
>> >
>> > >> > thanks for attention.
>>
>
>