.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

asp:FileUpload for Android

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

I've read several older posts about the lack of compatibility of the asp:FileUpload control with Android phones.

My Android phone renders the control but it taping the "Select File" does nothing.

First, is this still the case?

Second, do other browsers running on an Android device get around this problem?

Third, is this a .NET issue or an Android issue?  In other words, doesn't the .NET control simply render a normal HTML <input> tag?

Lastly, does anyone know of a current or prospective solution to this glaring weakness?


View Complete Post

More Related Resource Links

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Develop with C# on the Android? Sure - Introducing MonoDroid

Incase you haven't heard of MonoDroid before, it is a future product to be released by Novell which allows you to use C# and the .Net framework to develop applications on an Android device. If this sounds something you're interested in, then make sure you sign up here - http://go-mono.com/monodroid/ On Wednesday night a Private Preview went out to 250~ developers, this release is not to represent a release worthy product of MonoDroid, nor be bug free, but a Community Tech Preview, to borrow a Microsoft...(read more)

FileUpload Class SaveAs, how can you overwrite?

Hello all,

I'm trying to use 2.0 class, FileUpload. 
Namespace: System.Web.UI.WebControls
Class FileUpload

Anyway, in my code can save the file to the server

FileUpload1.SaveAs(SavePath + FileName)

Problem is I can't find a way to overwrite the file.  When I try and run the program again is says the file is already in use that a process has access to it.

Is thre a proper way to release control of whatever it grabbing hold of it?  In .Net I don't have to destroy my objects right?
Or is there a way to specificly overwrite the file? It seems that SaveAs does that.  Just trying to figure out why I can upload this text file, but sometimes only once and then I have to code in to check to see if it exists then rename it.

FileUpload error: Object reference error


I have a FormView with a FileUpload to upload an image in a database.

I keep getting an object reference error.(view code)

I am using this same script to upload the image to the database, but when I try to update the file upload I get the error.    

string strFilePath=Server.MapPath("\\images\\"+fupdImage.FileName);

        Byte[] image=null;
        HttpPostedFile imgVid=FileUpload.PostedFile;

        image=new Byte[imgVid.ContentLength];//Object reference not set to an instance of an object.

        if(FileUpload.HasFile) {
        string imageFile=FileUpload.PostedFile.FileName;
        int index=imageFile.LastIndexOf(".");
        string fileFormat=imageFile.Substring(index+1);


FileUpload.SaveAs is configured to require a rooted path. but "http:// --- is not a rooted path


Hi Friends

when i am uploading image to http://filepath i got the 

The FileUpload.SaveAs Method is configured to require a rooted path but http:// filepath is not a rooted path

my code is as follows

If (Fileupload.HasFile)


Dim filepath As String = http://filepath/

FileUpload.SaveAs(filepath & String.Format("datafield_{0}_b.jpg", textbox.Text))

End If

Please help me




FileUpload Access Denied


Hi all.

I have done much research on this and am still stumped.

I have a ASP.NET 2.0 application, running on Windows 2003 Server. IIS 6.0

I am using Windows authentication , and I am not using impersonization, and I set my trust levvel to full.

<authentication mode="Windows"/>

<identity impersonate="false"/>

<trust level="Full

Detecting mobile device user agents in ASP.NET (Android)



Last week Android updated their software (changed the display from 480px to 800px) so all the mobile tweaks we made for our apps are no longer work on Droid Phones.

I would need to identify the User Agent(e.g. Android) and switch style sheets depending. (We don't want to redirect to another page, just switch style sheets).

Anybody know any lightweight solution ?

Thanks in Advance.

(we were using 480px pixels to identify if the user was coming from iPhone or Android and switched stylesheets accordingly.  If I changed it to 800px some desktop monitors and the iPad would see the mobile version and not the desktop version. Not good.)



FileUpload Control with membership and roles


Hi Everyone!

I'm pretty new to development using Microsoft technologies.

I'm trying to build a portal kind of an application in asp.net, in which one of the functionality is letting people log in and upload their documents. The upload page is only accessible to registered users of the portal.


I would like to track the user uploaded files according to their userIds.

Is it possible to use the FileUpload Control and C# to fetch the current user id, create a directory with the same name(as that of userID) in the file system and upload the files( multiple file upload, if necessary) into it?

Also another admin page would have to be able to see the list of files uploaded by the specific user and download it if necessary.

Could anyone help me with this?

I'm also expecting alternate solutions to the problem.

Awaiting a response.

Thanks in advance 


Getting an error using FileUpload Control on a server.

Hello FriendsI m getting a problem while executing the following code for my website.This code works perfactly on localhost but when I use d same code on my webpage on the server it does nothing...even it doesnt return any error msg.Plz help me...protected void BtnUpload_Click(object sender, EventArgs e) {        int intFileSizeLimit = 1000;               string strFileNameWithPath = FileUpload1.PostedFile.FileName;               string strExtensionName = System.IO.Path.GetExtension(strFileNameWithPath);              string strFileName = System.IO.Path.GetFileName(strFileNameWithPath);           int intFileSize = FileUpload1.PostedFile.ContentLength / 1024;                              strExtensionName = strExtensionName.ToLower();        if (strExtensionName.Equals(".doc") || strExtensionName.Equals(".txt") || strExtensionName.Equals(".docx"))        {      

few questions about fileupload control

hey im currently using this to save pictures to a certin folderImgUpload.SaveAs(Server.MapPath("../Img/") + ImgUpload.FileName); my questions is 1. how do i avoid rewriting an image, in other words how do i check if there is another file using the same name? 2. how do i iterate on each image in the folder so that i can print certin html code for each img like for each image print this -> (<img src="Image_Path/Image-name.jpg/gif" width="?" height="?">   tnx

UpdatePanel and FileUpload

Hi, i have wide customer table that i handle with a big DetailView nested inside an UpdatePanel for faster interaction. Works like a charm. Now they ask me to allow the user to upload a file, but when i add it in the detail view and i save data i get no file at all, as if putting it into an updatepanel do not allow him to send the file any more. Is there some setting i have to put so to make it work ? thanks in advance, Fabrizio

GridView EditItem FileUpload validation

Hey allI am using a gridview that contains an asp:fileupload so that when the user clicks 'edit' they can upload a pdf. I need to validate the size of the file, it needs to be less then a certain size. I tried to use a custom validator, but it never get called when the user updates. Is there a way to do this? How can I validate the file size on edit in the gridview?Thank youAaron

Using FileUpload and GridView controls

Hi to all,I have four controls in my page: FileUpload, LinkButton, GridView, and Button.FileUpload - I use the control to browse and open an Excel file in the client machine.LinkButton - I use the control to trigger the method that copies the Excel file to the server, converts the data of Excel file to DataTable, deletes the Excel file, and returns the DataTable.GridView - I use the control to display the data.Button - I use the control to save the data to the database.I did not see any problem until I uploaded the third file that hanged my page. I noticed that every time I upload a file, the page become slower gradually.Each Excel file has 2,000 records, and every time the GridView displays an item, it searches the data on the database. I think, the more the data in the database, the slower the searches can be.To solve this problem, I set the AllowPaging property of GridView to true. The less displaying of items, the less searching of data can be. But, every time I change the page of GridView, I have to bind again the data to the GridView. In order to bind the data, FileUpload must contain the source file, but not because FileUpload frees the file when the page posts back. And I don't want the user browses the file every time he changes the page of GridView. That is very tedious.Does anyone have encountered this kind of problem? Please share us your solution.Your responses


i can successfully upload, view and load an excel file into my webapp then into my db.  However when i go to upload a second time i keep getting the following error msg: The process cannot access the file <myfilename> because it is being used by another process. Now before everyone starts telling me to use .Dispose.. I am, everywhere I can..and I've isolated it to just the using the view functionality as a test... once viewed (connected to xls sheet) then file becomes "locked" and doesn't seem to relese.  Below is the code.  I am looking for any advice on what I am missing to unlock and reupload. thanks I got this from 4guysfromrolla.com however they don't cover this issue i've encountered. ---gets my file  (notice the fileuploadexcel object is being disposed-bolded) Protected Sub upload(ByVal sender As Object, ByVal e As System.EventArgs)         Dim fname As String        fname = Session("usr").ToString & "_Xlimp.xls"         If FileUploadExcel.HasFile Then            Try                'alter path for your project       

FileUpload control loses value on postback.

I'm having a little problem with my file uploading. Does anybody know how to maintain the value in the FileUpload control between server posts?I have a form which, among other things, uploads a file. I am using an FileUpload control (created dynamically) to let a user browse their PC for a file and then using the SaveAs method to upload the file to the server.When I'm selecting a file and Click on Next button for processing then selected file is lost.Same is happening with me with HtmlTextArea (dynamically generated) , the problem was that I was not again re-initializing the controls after postback. What I did is re-initialized it in Init method of placeholder (as I have created/placed all dynamic controls in placeholder ).But this thing is not working for fileupload control. I found solution in one of the forum is that "use hiddenField Control to transfer the selected file from the client to server"but this mechanism will only help to retain the name of file in a hidden variable and the FileUpload1.PostedFile.SaveAs(filename) will not work bcz of absense of object (fileupload1).here is code:protected void lnkbtnNext_Click(object sender, EventArgs e) { if (Session["pnl"].ToString() == "0") { /* other stuff code */ } else if (Session["pnl"].ToString() == "1")

How to get the filepath in a fileupload into a textbox and vice versa.

Hello forum I was wondering how to place a  filepath value, in a fileupload, into a textbox or a filepath value in a textbox into a fileupload.  Like the reletionship between a textbox and dropdownlist would be txtbx.text = ddl.selectedvalue and vice versa. Thank you

How to Set default file name of image in FileUpload Control

helloi want to set  default value in Fileupload control.Because when i select file name using fileupload then save that file to sqlserver database i got problem when no file is select. so i found alternate of that i should store default image into database through fileupload control but now my query is how to set default image to fileupload control.please i want source code.i really need it......tnx in advance
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend