FineUploader / fine-uploader

Multiple file upload plugin with image previews, drag and drop, progress bars. S3 and Azure support, image scaling, form support, chunking, resume, pause, and tons of other features.
https://fineuploader.com
MIT License
8.19k stars 1.88k forks source link

Doesn't work on Android #82

Closed ghost closed 11 years ago

ghost commented 13 years ago

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 commented 13 years ago

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 commented 13 years ago

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

syslogic commented 13 years ago

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

syslogic commented 13 years ago

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 commented 13 years ago

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 commented 13 years ago

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

igloox commented 13 years ago

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 commented 13 years ago

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

Thanks,

bayarmunkh commented 13 years ago

It works. Excellent!.

oviroa commented 13 years ago

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

oviroa commented 13 years ago

@ bayarmunkh how did you make it work?

bayarmunkh commented 13 years ago

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 commented 13 years ago

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

syslogic commented 12 years ago

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

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

bgrandgeorge commented 12 years ago

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 commented 12 years ago

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

bgrandgeorge commented 12 years ago

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):

Deivi commented 12 years ago

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 commented 12 years ago

Anyone confirmed the above patch/rewrite fixes it?

a-c-m commented 12 years ago

Confirmed, the above fixes the issue.

entropie commented 12 years ago

Confirmed too. Thanks Deivi.

luxifer commented 12 years ago

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 commented 12 years ago

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

DGuidi commented 11 years ago

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

rnicholus commented 11 years ago

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

rnicholus commented 11 years ago

Will research this in 3.0.

rnicholus commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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.