Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Doesn't work on Android #82

Closed
ghost opened this issue Dec 13, 2010 · 31 comments
Closed

Doesn't work on Android #82

ghost opened this issue Dec 13, 2010 · 31 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Dec 13, 2010

Greetings,

When I try to use valums file uploader on Android, it doesn't work. Returns some error about the file being uploaded having a size of 0.

@syslogic
Copy link

I can confirm this issue ... it's not just filesize = 0 ... it's file = undefined

when it's passed to the validation... so it bugs out before that already.

@syslogic
Copy link

it complains about 'wrong file type' or 'file size is zero' ... but the reason is = file = undefined.

@syslogic
Copy link

Just have tested, not only the Android stock browser is affected - FireFox 4 has the same problem.

@syslogic
Copy link

Think this issue might be related to this bug:
https://bugs.webkit.org/show_bug.cgi?id=23933

Any chance to get synchronous AJAX calls for mobile browsers?

@igloox
Copy link

igloox commented Apr 28, 2011

Firefox 4 works fine for me, but the stock browser on Android 2.3 and the webkit-based 'Midori' browser appear to exhibit the same problem.

At the very least, is there a way I can force those browsers to use the legacy iframe method until this gets straightened out?

@ghost
Copy link
Author

ghost commented Apr 28, 2011

Android browser doesn't support uploading. Nothing to do with this excellent project...

@ghost ghost closed this as completed Apr 28, 2011
@ghost ghost reopened this Apr 28, 2011
@igloox
Copy link

igloox commented Apr 29, 2011

Android browser doesn't support uploading. Nothing to do with this excellent project...

Yes it does, at least as of 2.3, possibly earlier. I've been doing it all week. It even works with Blueimp's jQuery-File-Upload

edit: I've just tested, it even works with 2.2

@bayarmunkh
Copy link

It doesn't work on Adroid 2.3. I got the same error that says 'EmptyError.' Does anyone have an idea?

Thanks,

@bayarmunkh
Copy link

It works. Excellent!.

@oviroa
Copy link

oviroa commented May 18, 2011

It stil won't work for me. Still get the EmptyError. I am on 2.3 on a Nexus one.

@oviroa
Copy link

oviroa commented May 19, 2011

@ bayarmunkh how did you make it work?

@bayarmunkh
Copy link

I am not sure, is it a good idea. But, you can try.

In the _ValidtateFile section, change following thing.

    } else if (size === 0){
        this._error('emptyError', name);
        return false;

To :

    } else if (size == undefined){
        this._error('emptyError', name);
        return false;

It worked on my Android (My Touch 4G).

Thanks,
Bayarmunkh

On Thu, May 19, 2011 at 12:04 PM, oviroa <
reply@reply.github.com>wrote:

@ bayarmunkh how did you make it work?

Reply to this email directly or view it on GitHub:
https://github.com/valums/file-uploader/issues/82#comment_1204844

Regards,
Bayarmunkh
chiigle@gmail.com
chiigle@gmail.com
Cell Phone: 641/233-0537

@oviroa
Copy link

oviroa commented May 19, 2011

Didn't quite work. Error is gone but file doesn't get uploaded. Ideas?

On 5/19/11 10:12 AM, "bayarmunkh"
reply@reply.github.com
wrote:

I am not sure, is it a good idea. But, you can try.

In the _ValidtateFile section, change following thing.

   } else if (size === 0){
       this._error('emptyError', name);
       return false;

To :

   } else if (size == undefined){
       this._error('emptyError', name);
       return false;

It worked on my Android (My Touch 4G).

Thanks,
Bayarmunkh

On Thu, May 19, 2011 at 12:04 PM, oviroa <
reply@reply.github.com>wrote:

@ bayarmunkh how did you make it work?

Reply to this email directly or view it on GitHub:
https://github.com/valums/file-uploader/issues/82#comment_1204844

Regards,
Bayarmunkh
chiigle@gmail.com
chiigle@gmail.com
Cell Phone: 641/233-0537

Reply to this email directly or view it on GitHub:
https://github.com/valums/file-uploader/issues/82#comment_1204897

@ghost ghost assigned valums Jun 22, 2011
@syslogic
Copy link

file = undefined ... that is the main problem.

tweaking the validation is just non-sense if there's nothing to validate.

@bgrandgeorge
Copy link

Guys, I did this, and it works on my galaxy tab:

        else if (size === 0){            
        //    this._error('emptyError', name);
        return true;

Only problem with this is that it screws up the cancel when you want to NOT upload after clicking upload... But I can live without it for a while! (the cancel while uploading still works)
The problem is that Android browser(s?) are not reporting the file size... Not sure if it is an android issue, or a browser issue... is there a chrome for android?

@syslogic
Copy link

syslogic commented Sep 2, 2011

haven't test this yet, but maybe it should be combined with a check for mobile browsers.

@bgrandgeorge
Copy link

Yes, like in the case of the safari browser... Not exactly sure what to put though.

Here is the browser info on my Galaxy tab (with default browser and Gingerbread):

  • Browser CodeName: Mozilla
  • Browser Name: Netscape
  • Browser Version: 5.0 (Linux; U; Android 2.3.3; en-gb; GT-P1000 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
  • Cookies Enabled: true
  • Platform: Linux armv7l
  • User-agent header: Mozilla/5.0 (Linux; U; Android 2.3.3; en-gb; GT-P1000 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

@Deivi
Copy link

Deivi commented Sep 13, 2011

Thank you very much to solve the problem mate, I've added a few lines of code for just when browsing devices remove this._error androids ('emptyError', name) and return true. This is implemented:


_validateFile: function(file){
        var name, size;
        // Stores data from operating system and browser you are using.
        var uagent = navigator.userAgent.toLowerCase();
        var deviceAndroid = "android";
        var deviceMobile = "mobile";
        
        if (file.value){
            // it is a file input            
            // get input value and remove path to normalize
            name = file.value.replace(/.*(\/|\\)/, "");
        } else {
            // fix missing properties in Safari
            name = file.fileName != null ? file.fileName : file.name;
            size = file.fileSize != null ? file.fileSize : file.size;
        }
                    
        if (! this._isAllowedExtension(name)){            
            this._error('typeError', name);
            return false;
            
        } else if ((size === 0) && ((uagent.search(deviceAndroid) > -1) || (uagent.search(deviceMobile) > -1))) {
            return true;
        
        } else if (size === 0)  {
            this._error('emptyError', name);
            return false;
            
        } ......

Many greetings to all.

@a-c-m
Copy link

a-c-m commented Nov 4, 2011

Anyone confirmed the above patch/rewrite fixes it?

@a-c-m
Copy link

a-c-m commented Nov 4, 2011

Confirmed, the above fixes the issue.

@entropie
Copy link

Confirmed too. Thanks Deivi.

@luxifer
Copy link

luxifer commented Jan 16, 2012

I just change the


} else if (size == 0){
  this._error('emptyError', name);
  return false;

to


} else if (size == undefined){
  this._error('emptyError', name);
  return false;

and it worked fine for me ;)

@njam
Copy link

njam commented May 2, 2012

It seems to me the Android 2.3 browser wrongly sets both the "size" and "fileSize" property of a selected file to zero.
Tested with the SDK emulator and http://jsfiddle.net/VgZnh/
I find it odd that there seems no other discussion about this anywhere - does anyone see another reference/bug report?

I think the only workaround is to ignore size===0: https://github.com/cargomedia/file-uploader/commit/c727082f5b45b9c15c380d264ca4ce9587c90df7

@ghost ghost assigned rnicholus Sep 22, 2012
@DGuidi
Copy link

DGuidi commented Nov 9, 2012

@Deivi patch works also for me with Samsung Galaxy TAB.
Thanks @Deivi :

@rnicholus
Copy link
Member

Note that I will be fixing this for good, hopefully, in 3.1. I have identified this as a priority 1.

@rnicholus
Copy link
Member

Will research this in 3.0.

rnicholus pushed a commit that referenced this issue Nov 13, 2012
…ng regression also found in Android 2.3.6
@rnicholus
Copy link
Member

I found an issue that prevented the response from being parsed in somewhat older Android versions. For example, in Android 2.3.6, xhr uploading is not supported, so Fine Uploader falls back to form submission. The stock Android browser (at least) adds the response as a child text node of <pre style="word-wrap: break-word; white-space: pre-wrap;">. I noticed this in the javascript console of my Galaxy S2, which is running 2.3.6. IE 7-9 will add the response as a child text node of a <pre></pre>, but without any attributes. The existing code that rips the response out of the <pre> element didn't take into account the 2.3.6 case, so I modified it and all appears to work well now.

Note that I realize this is not the Android issue described in the headlining message of this case, but since the case is title "Doesn't work on Android", I thought I'd throw this fix in here.

I'm still. looking into the 0-size issue.

@rnicholus
Copy link
Member

I'm having some trouble reproducing the 0-size file issue. I've attempted on both Android 2.3.6 and Android 4.0.4 (stock browsers on both). I uploaded several files, and while the file sizes were incorrect for files that were not locally stored, I was still able to upload. If someone is still seeing this issue, please re-open this case, report your version of Android, your browser, and the specifics of the file used to reproduce this. I'd hate to remove the 0-size check unless it is completely necessary. I suppose I could only disable this check if the UA string contains "Android", but I'd like some current reports from users that are experiencing this problem before I do so.

@abennouna
Copy link
Contributor

I used both 2.3.3 and 3.1 stock browsers with the demo webpage and only
thing that fails is the sizeLimit parameter ie I can upload files that are
bigger than that.

@abennouna
Copy link
Contributor

I tested with 2.3.6, same issue (I can upload files bigger than the sizeLimit). Other than that, everything seems to run ok.

Disclaimer: tested the Android versions only on the 2.1.2 and to-be-released 3.0 demo pages.

@rnicholus
Copy link
Member

2.3.6, and presumably 2.3.3 as well, does not support the file api, so this
is expected and unavoidable.
On Nov 14, 2012 5:39 AM, "tellibus" notifications@github.com wrote:

I tested with 2.3.6, same issue (I can upload files bigger than the
sizeLimit). Other than that, everything seems to run ok.

Disclaimer: tested the Android versions only on the 2.1.2 and
to-be-released 3.0 demo pages.


Reply to this email directly or view it on GitHubhttps://github.com/valums/file-uploader/issues/82#issuecomment-10363235.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests