Answered by:
Mobile File Upload

Question
-
User-1501389609 posted
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.
Tuesday, February 19, 2008 6:20 PM
Answers
-
User-1136466523 posted
Hi,
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.
Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, February 20, 2008 10:19 PM
All replies
-
User-1136466523 posted
Hi,
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.
Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, February 20, 2008 10:19 PM -
User-1501389609 posted
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?
Thursday, February 21, 2008 10:36 AM -
User-1136466523 posted
Hi,
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.
Thanks.
Thursday, February 21, 2008 9:16 PM -
User-45530239 posted
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.
.ASPX page:
<mobile:Form ID="Form1" Runat="server">
<mobile:DeviceSpecific ID="dd" Runat="server">
<Choice>
<HeaderTemplate>
<input style="width: 389px; height: 22px" type="file" size="45" runat="server" id="FileUpload1">
</HeaderTemplate>
</Choice>
</mobile:DeviceSpecific>
<mobile:Command ID="cmd_Upload" Runat="server" OnClick="cmd_Upload_Click">Upload</mobile:Command>
<mobile:Label ID="Label1" Runat="server">
</mobile:Label>
</mobile:Form>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
Thursday, March 20, 2008 3:40 AM -
User809794692 posted
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.
Thanks.
Wednesday, May 21, 2008 3:09 PM -
User606025103 posted
Hi,
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.thank you.
Monday, August 4, 2008 1:10 AM -
User1315235872 posted
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
Thursday, May 28, 2009 1:18 AM -
User2098947605 posted
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" by default.
<filter name="supportsFileUpload" compare="supportsFileUpload" argument="true"/>
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.
Any ideas?
Thanks
Thursday, June 11, 2009 5:15 PM -
User2072767153 posted
is anybody got the solution of this problem. I need the solution of this as soon as possible.
Thanks All
Thursday, April 1, 2010 2:32 AM -
User505388462 posted
So the Conclusion is No File Upload in Mob Web App Right ???
Saturday, April 9, 2011 9:00 AM -
User-2080168305 posted
what is the final answer??
how i can achieve Uploading Functionality on most of all SmartPhones in our Mobile Website?
Thanks.
Monday, May 23, 2011 8:29 AM -
User505388462 posted
Browsing a mobile website (which is hosted in a Server) with a browse control to upload images to the Server.
- Windows Phone 7 - Is the latest from Microsoft, which will support in the rendering of uploader control in its native browser and also can upload images.
- iPhone - Doesn't allow any of the other application to browse its galleries. Till the latest version.
- Windows Mobile - Not rendering the uploader control in the browser.
- Black Berry - Fully supports browsing and uploading of images in its native browser.
- Android - From version 2.0 or above will support browsing and uploading of images and music files only.
Tuesday, May 24, 2011 2:38 AM -
User587316579 posted
iOS 6 can now upload images and videos.
You can also use filepicker.io to do mobile uploads. It’s a developer javascript plugin that allows you upload files from the cloud, like Dropbox, Box, Facebook, Gmail so your users can use your website and upload content.
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.
Monday, June 25, 2012 2:51 PM