11

This question has been asked before, but not this year - there is no concrete consensus and I know this is a hot topic. In addition, technology changes rather quickly, and the other questions seem to relate to only using the <input type="file>. I am looking for a more verbose modern way to handle these requests. Although I have been developing in ASP.NET C# MVC3, I have been looking into weather ASP.NET MVC4 Mobile will support mobile file upload. From what I have read, it does not, or it has not been covered in the new release notes.

http://www.asp.net/vnext/overview/whitepapers/whats-new

http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features

From the research I have done jQuery-Mobile seems rather gimmicky.

http://www.parorrey.com/blog/jquery-mobile/file-input-field-uploading-using-jquery-mobile-framework-form-submission-with-ajax-disabled/

http://forum.jquery.com/topic/jquery-mobile-seems-to-clobber-ability-to-upload-files-via-forms

An example that was posted did not work on my iPhone, as the <input type="file" still existed and was therefore grayed out as inaccessible.

http://filamentgroup.com/examples/jquery-custom-file-input/

Another suggestion I have come across involves forcing the user to email the photo to a user-specific email which doesn't really appeal to me or the customers I deal with - this approach also seems like it could be vulnerable to security breaches.

IS there a way to do this that I have overlooked? How can I show a file dialog on a mobile device?

Travis J
  • 81,153
  • 41
  • 202
  • 273
  • There is a [blog post from Dec 2012](http://viljamis.com/blog/2012/file-upload-support-on-mobile/) that claims that most of the current mobile browsers (iOS 8.0.2+, Android 2.2+, Windows Phone 8.1) support file uploads. – amoebe Oct 13 '15 at 15:50

8 Answers8

3

The Safari browser does not support file uploads. You can see this by visiting many of the mobile sites in the actual browser BUT the actual apps will allow this.

So if you are making a mobile web app that you wish to deploy as a native app, you can use phonegap as a layer to do this.

http://docs.phonegap.com/en/1.4.1/phonegap_file_file.md.html#FileTransfer

Also, it is supported in:

  • Android
  • BlackBerry WebWorks (OS 5.0 and higher)
  • iOS
  • Windows Phone 7 ( Mango )
zSprawl
  • 969
  • 7
  • 11
1

I use jquery mobile in a production app and it works just fine. I don't do file upload with it; however, that isn't jquery mobile's job anyhow. JqueryUI has issues with its dialog and file upload as well. There are a number of scripts that help with that. I use ajaxfileupload: http://www.phpletter.com/Our-Projects/AjaxFileUpload/ there are better ones out there now though.

I digress. As far as mobile is concerned it is more useful to have camera features involved rather than pure fileupload. No one knows where they store things on their phones, which is part of the problem. For that case you may want to try phonegap. Try this: http://wiki.phonegap.com/w/page/18270855/Image%20Upload%20using%20JQuery%20and%20Python

Parris
  • 17,833
  • 17
  • 90
  • 133
  • From the reading provided, and from phonegap.com, it seems that phoneGap is an application that is installed on the mobile device and then referenced through a webapp. I could make an application which simply submitted pictures to my webapp using a cross-platform mobile delivery system, but was hoping to find a native way to accomplish picture uploads. The camera upload feature is very interesting though, thank you for your suggestion. – Travis J Jan 15 '12 at 23:21
1

Yes we can upload picture through mobile, Face book is a live example for this.

shyamshyre
  • 539
  • 3
  • 5
  • 10
  • 1
    Facebook runs horribly through my iPhone browser, and will not even load. I have seen it run on a different iPhone and there is no where to upload pictures through. I believe you are thinking of the facebook application - which really has no relation to this question. – Travis J Jan 23 '12 at 20:33
  • 1
    Agree... facebook web browser doesn't upload pictures. The facebook application which has access to the FS does. – Bot Jan 26 '12 at 15:20
1

It works for me on Android.

You can see how facebook does it here: https://m.facebook.com/home.php?refsrc=http%3A%2F%2Fm.facebook.com%2F&refid=8&_rdr

<input type="file" name="file1" data-sigil="photo-input" />

Try going to www.tinypic.com and uploading a photo. I can test on iPhone tonight.

Dan
  • 647
  • 6
  • 9
  • tinypic will not allow me to upload a picture from my iPhone, the input is grayed out. Does it work on your android phone? On an iPhone, any input with type="file" is grayed out. – Travis J Jan 27 '12 at 21:20
  • I can not even load a single page of facebook on my iPhone aside from the login. – Travis J Jan 27 '12 at 21:20
  • 1
    This works for me on my Android phone, but it does NOT look like it's possible in iPhone right know... as Safari is preventing any upload interaction. The only current work around is to build an app. http://stackoverflow.com/questions/3891831/a-html5-web-app-for-mobile-safari-to-upload-images-from-the-photos-app – Dan Jan 27 '12 at 21:25
  • Hm..it is nice that it at least works on the Android. I am able to get the file path from the iPhone for pictures. When you say "upload interaction" does this imply browsing for files or the actual upload of data, because I am certain that the iPhone browser does allow some content to be uploaded when browsing such as location, or user agent. – Travis J Jan 27 '12 at 21:29
  • **Update**: On iOS v6+, "media uploading" is supported in Safari. So while it looks like you cannot upload arbitrary files out of the box (though Android is the same) there is at least now the possibility of accomplishing photo/video uploads via an HTML form on both Android and iPhone. http://www.macworld.com/article/1168499/hands-on-with-ios-6-safari.html – Colin Fukai Dec 28 '12 at 00:53
1

This works fine on Android 2.2+. You can upload photos from your gallery or use the camera to take a new picture for uploading. Any other apps that expose similar behaviour like sound recorders, the camcorder and music apps will typically offer alternatives. If you have a good filesystem app installed this will normally allow you to upload arbitrary files.

On iOS, you have to use an app to upload files. Since this is such a glaring omission in this age of web apps, it is very likely this feature will be added in the next major release of iOS although that is likely a few months away still.

adamnfish
  • 10,935
  • 4
  • 31
  • 40
  • Kinda vague ("this works fine"). Can you extrapolate? Are you saying that `input type=file` will work properly on Android 2.2+? – Travis J Feb 15 '12 at 19:17
  • It works as I've described (so "yes" :) )! You get at least gallery, camera and camcorder as sources out of the box and other options created by other apps that are installed / came with the user's OS (e.g. sound recorder, music, file managers). If you want to try it yourself you can run the emulator in the Android SDk and browse to a site with a file input. – adamnfish Feb 15 '12 at 21:27
0

Try this:

<input type="file" accept="image/*;capture=camera">

This should be supported in most mobile browsers and should offer the user a chance to choose a local file (image) or one some modern devices even allow them to capture one in the process.

Hope this helps!

shanabus
  • 12,989
  • 6
  • 52
  • 78
-1

Use Phonegap to bridge the gap between client side libraries and native applications. While the client side libraries give a good handle and easy way to set UI things up, you can use the capability of phonegap to perform device specific operations like camera, scanning, call etc.

Liam
  • 2,837
  • 23
  • 36
  • 1
    PhoneGap is not for mobile web applications. All it does is allow you to write applications in javascript and have it deployed similar to native. – Bot Jan 26 '12 at 15:22
  • Agree so why down vote, I said to use phonegap in order to bridge the gap. Please read my answer properly before down voting. – Liam Nov 24 '14 at 20:47
-1

Mobile browsers in Android (pre 2.2 it seems) and iOS do not allow file system access. And when it does on Android 2.2+ it isn't full access - it is filtered via apps that hit the FS like Gallery or Music.

aknosis
  • 3,602
  • 20
  • 33
  • If the filepath was known could the picture be pulled from them? – Travis J Jan 17 '12 at 18:46
  • Not that I am aware of. I myself think that the fs is blocked from the browser to push people towards having to create legitimate apps thus increasing the respective app store traffic. – aknosis Jan 17 '12 at 21:57
  • 2
    This is not true for Android! While Android does not have a built-in filesystem manager, the user can install their own at any time which will expose filesystem uploads. Even without this, you can still upload resources from other apps like the gallery (for pictures) and the camera (for taking a fresh picture for upload). – adamnfish Feb 15 '12 at 21:29