Last post Sep 01, 2009 08:27 AM by anantjains
Aug 10, 2007 04:24 AM|apurva kaushal|LINK
Is it possible to give the file upload functionality in a mobile web page?
I tried to use fileupload control in asp.net 2.0 under devicespecific section. It is rendering correctly but when I am selecting a file and submitting that HasFile always returns null.
I also tried will classic file upload control i.e. input type=file but there also it is giving postedfile as null.
Jul 07, 2009 07:09 AM|faraz45pk|LINK
Did you find any answers for FileUpload in Mobile devices?
Sep 01, 2009 08:27 AM|anantjains|LINK
Try the following:
1. make sure you are not using Master pages.
2. Make sure your file upload is not inside UpdatePanel control. (I hope this is not the case.)
3. Add the traces to check if the hfc.Count is non 0.
If it is 0, that means something terribly wrong with the fileupload control. Try uploading the file whose file name length is less than 10 characters (excluding extns) as IEMobile has a bug saying it will not upload file whose filename is more than 10 char.
4. Check if the server is having permission to save file under C:\ drive. If not create a temp folder and replace hpf.SaveAs("C:\\" + Path.GetFileName(hpf.FileName)); with hpf.SaveAs("C:\\temp\\" + Path.GetFileName(hpf.FileName));
i am able to see file getting uploaded with my code. I am trying with LG device.
Here's my code snippet
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MobileApp.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="form1" runat="server">
<asp:FileUpload ID="FileUpload1" runat="server" Width="416px" /><br />
<asp:Button ID="Button1" runat="server" Text="Button" Width="111px" OnClick="Button1_Click" /></div>
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
hpf.SaveAs("C:\\temp\\" + Path.GetFileName(hpf.FileName));
//"Empty File, please select file before clicking upload button";
do you still have problem?