Last post Jun 25, 2012 02:51 PM by dchang
Feb 19, 2008 06:20 PM|osbornm|LINK
Hey, I have a asp.net mobile website that i would like users to be able to upload photos from there phone to the site. What are some solutions for this and if there are mroe then one what is the best practice? Thanks so much.
Feb 20, 2008 10:19 PM|Nai-Dong Jin - MSFT|LINK
From your description, it seems that you want to upload files in your ASP.NET mobile web application, right?
Let’s separate your target users into two parts. For users whose devices embedded with Windows Mobile 6 OS, the problem seems to be easy. In Windows Mobile 6, the web browsing experience is much better. Internet Explorer Mobile can access more sites because
it reports that it is MSIE 6.0. (The connect string is Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 6.9).) In addition, it includes the ability to select and upload a local file to a Web server.
But for those users who do not have a WM6 embedded device (i.e Nokia,Motorola and etc…), we should achieve it manually.
Generally, you can try to create an upload page that posts the selected file to an Upload Process page. (say we call it UploadProgress.aspx) And in that page, try to get the input stream from Request.Files collection. Here, HttpFileCollection stands for
the collection of the files which come from the client side. And we also should note, only when the content-type is “multipart/form-data”, the collection will be filled.
After that, create an HttpPostedFile typed object to receive the files in the file collection. Then, you may save it both in file system and database (using BLOB typed field to save the content).
Besides, as far as I know, there’s a maximum size limit on file transferring. It does not related to your application, it relates to your local mobile telecommunication service provider. These kinds of limit can be set on WAP gateway. In most of the cases,
that’s the reason why your application works on simulator, or any WML supported explorer, but not works in a real device.
Just some suggestions for you. Hope that helps.
Feb 21, 2008 10:36 AM|osbornm|LINK
Excellent one more question for you though, I am completely new to mobile asp.net so the easiest way for me to do this would be put a fileupload control ont here so they can broswe to the location on the device. but mobile does not support fileupload control
so how do i allow the users to broswer for the file?
Feb 21, 2008 09:16 PM|Nai-Dong Jin - MSFT|LINK
That’s right. ASP.NET 2.0 itself does not have a mobile form. The Mobile form is part of the v1.x support for Mobile Controls. There is no 'file upload' control in the mobile controls.
We can see in .NET 2.0 controls, we do have a file upload control <asp:fileupload which provides some mobile support. This is acheived using adapters and also a capability on the browsercapabilities called supportsFileUpload.
Then if a device can support the file upload mechanism, then a rendering is made, if not then alternate text or nothing will be rendered.
Mar 20, 2008 03:40 AM|jay4ever_2000|LINK
sir i am using this concept for my development can u help me my mobile .aspx and code behind is below
i am using HTML FIle INPUT to upload the file.
<mobile:Form ID="Form1" Runat="server">
<mobile:DeviceSpecific ID="dd" Runat="server">
<input style="width: 389px; height: 22px" type="file" size="45" runat="server" id="FileUpload1">
<mobile:Command ID="cmd_Upload" Runat="server" OnClick="cmd_Upload_Click">Upload</mobile:Command>
<mobile:Label ID="Label1" Runat="server">
CODE to uplaod :
HttpFileCollection uploadFilCol = Request.Files;
//HttpPostedFile file = uploadFilCol;
for (int i = 0; i < uploadFilCol.Count; i++)
HttpPostedFile file = (HttpPostedFile)uploadFilCol[i] ;
string fileExt = Path.GetExtension(file.FileName).ToLower();
string fileName = Path.GetFileName(file.FileName);
file.SaveAs(Server.MapPath("./Test/") + fileName);
still i am not able to upload the any files ....
please help me and send me your code if you have ....pls i need urgent help
May 21, 2008 03:09 PM|nshukla|LINK
I have a very similar requirement where the user wants to upload photos on the field. Did you get this working. Can you please send me your code.
Aug 04, 2008 01:10 AM|chetanpawar|LINK
I the same requirment i have, i am using general asp.net. code for the same,
I was sucessful in work from opera mobile browser.
Opera opens the oprn file dialog box with folder level same as desktop windows os.
Now when triend on Windows IE browser it wont be upload, the error becoz of the format of open file dialog box.
it shows all files in card or system memory in a glance, so when http post method with multi part try to find source file path it fails, and general server.mappath methods not useful for the same. bcoz it shows web server path, for this IE problem can any one
have some solution please poste here.
May 28, 2009 01:18 AM|jintomon|LINK
above code still not working in my mobile c#.net mobile form... Because the count always becomes zero in the above coding. please give a working code as early as possible
Jun 11, 2009 05:15 PM|AlexB1318|LINK
I've got a similar problem. I originally wrapped the DeviceSpecificControl in a isHTML32 choice. All of the code executed but I never got any uploaded file. I took your advice and added the following line to web.config since there was no "supporsFileUpload"
However, now I'm getting the error:
Can find neither a device capability named 'supportsFileUpload' nor a public non-static method on the page named 'supportsFileUpload' that returns a System.Boolean and takes
System.Web.Mobile.MobileCapabilities and System.String as arguments.
Apr 01, 2010 02:32 AM|varun007|LINK
is anybody got the solution of this problem. I need the solution of this as soon as possible.
Apr 09, 2011 09:00 AM|samgeorgejhm|LINK
So the Conclusion is No File Upload in Mob Web App Right ???
May 23, 2011 08:29 AM|Chintan Dave|LINK
what is the final answer??
how i can achieve Uploading Functionality on most of all SmartPhones in our Mobile Website?
May 24, 2011 02:38 AM|samgeorgejhm|LINK
Browsing a mobile website (which is hosted in a Server) with a browse control to upload images to the Server.
Jun 25, 2012 02:51 PM|dchang|LINK
iOS 6 can now upload images and videos.
It basically handles all the oauth and returns to you a URL. It's a way around the fact that the file input dialog is limited.
Full disclosure: I’m one of the authors.