.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

FileUpload Control........

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :.NET Framework

Hi..This is Rabbani Shaik..

In project,I got a situation such a whay that...My form contains a fileupload control and 3 dropdownlist controls..The data is binded this dropdowns from the databaase.so, we need complete autopost back right.Now i browse a file and select a item from the dropdown..then what will happen is  the path which i selected earlier is got vanished.Now my requirement is i want to hold the eventhough the page is posted back...Plz give some idea on this..

Thank u....

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

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

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 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

not retaining value of fileupload control in asp wizard control


I am developing a web application in asp.net and c#. I'm using an asp wizard control. there is  6 wizard steps in my wizard. In each phase im using many controls, so that many postback is done during execution.
I am using a asp fileupload control in second wizard step. My problem is that the value selected using fileupload control is not getting when i click wizard finsh button in the final step. values acquired using all other controls are available there.
Hope someone help me.
I just want to get the selected filename in last step. 

get full path from fileupload control in client side???


<script type="text/javascript" >

        function SetA()

                    document.form1.action = 'Default.aspx?fileName='+document.getElementById('FileUpload1').value;
    <form id="form1" runat="server">
        <asp:FileUpload ID="FileUpload1" runat="server"  />
        <asp:Button ID="btnupload" runat="server" Text="Upload" OnClientClick="SetA()" />



here in the  javascript function i need send full path of upload control?


please help in this situation? if anybody knows other way of sending full path please tell?


thank you,

GridVeiw - EditItemTemlate - FileUpload Control


Hello all

I have a grid veiw binded to an object datasource and one of the fields is the path of an image.

I have in the edit item template a file upload control and a command button to allow the users to upload the image and update the db attribute but i cant figure out how to bind that file upload control to the appropriate database field.

I tryed having a hidden labelbox and an image control and bind that to the object datasource but how can i access the file upload control from c# code to upload the image and update the label or the image controls?

this is my code:

<asp:ObjectDataSource ID="odsProducts" runat="server" 
                                    SelectMethod="GetProducts" TypeName="Project.BLL.Product.Product">
                                <asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="False" 
                                    DataSourceID="odsProducts" CssClass="gvNormal" GridLines="None"
                                    EmptyDataText="No Recods Found" 
                                    AllowSorting="true" AllowPaging="true" PageSize="10">

add dynamically fileupload control


Hi Everyone,

               I have a requirement where i need to add fileupload controls dinamically when Add button is clicked.  In my form i have one Add button and one Save button.

Each time ADD button is clicked one fileupload control must be added to form and i succeded in getting this.

Here is the code

   static int i;
    FileUpload fuPic;
    protected void Page_Load(object sender, EventArgs e)
        if (Session["pnl"] != null)
            Panel pnlfinal = (Panel)Session["pnl"];


protected void btnAdd_Click(object sender, EventArgs e)
        if (i <= 4)
            i = i + 1;

Security permissions - fileupload control



Is it only possible to the asp.net worker process to write files to a server folder?

The reason I ask is I need to create folders, store the files using the fileupload control to a file server. My IT colleague is saying that IIS is not installed on this server and hence cant use asp.net process. Is this the only account you can use to create folders/write files to a server? This is a separate server I am trying to write to, and not writing it to the same web server which the application sits under.

Is it possible to use another domain account to write files to a file server?

Many thanks.

Setting a Default Image for the FileUpload Control





I am trying to find a way of setting a default image(e.g. file path) for the FileUpload control so that a default image can be used if a user did NOT choose to upload an image.




FileUpload control



I want to filter the Xml file  alone while open file dialog ..


How to i filter the Condition in  File upload Browser time..

I have an idea abt windows application Open dailog i want in web application. urgent ..






uploading Image from client to server without using fileupload control



I have a requirement to read an image from client machine and to save the same in server, the path and filename of the image is fixed, i want to

done this task without using a fileupload control. Is there any way to accomplish this task?

Add images in Image Rotator With the Help FileUpload Control

The article Add images in Image Rotator With the Help FileUpload Control was added by codenickel on Saturday, October 30, 2010.

In case of ImageRotator we can use FileUpload Control To upload my images.Here I use it in a siple way:-Step 1:- we use Image Control (Image1),FileUpload Contol , Button(Button1..)and HiddenField ( for store the FileName), and a Save button to call the

Fileupload control image preview?


Hello, I have a little project I'm working on in which a form allows a user to add a product to a database. This form has a fileupload control for a product image, this feature works fine as far as actually inserting the uploaded image into the record, but I wondered if there is someway to dynamically display the image that was uploaded so that it can be previewed on the page before the user clicks to save into the database?

The following is my code for the page in question...

<%@ Page Title="" Language="VB" MasterPageFile="~/Admin.master" %>
<%@ Register assembly="System.Web.DynamicData, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %>
<script runat="server">
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