473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

File upload status

I am uploading a file from the file input box (textbox with a browse button)
but when you tell the file to upload the client doesn't see anything happen
until its done uploading... I'd love to provide some kind of visual feedback
(an animated image or something while it happens to show its going, and at
best a progress of the upload) is there anyway to do this in asp.net? thanks
Nov 18 '05 #1
2 1762
There are several different implementations in asp.net

One being the creation of custom handlers or custom content handlers, I dont
recall which. It would provide REAL per byte upload status etc.

Others just simply provide an estimation on the fly.

Check out www.codeproject.com, where there is an article on file upload
status, and in the comments, a link to the real nice one.
Weston Weems
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:ec**************@TK2MSFTNGP15.phx.gbl...
I am uploading a file from the file input box (textbox with a browse
button) but when you tell the file to upload the client doesn't see
anything happen until its done uploading... I'd love to provide some kind
of visual feedback (an animated image or something while it happens to show
its going, and at best a progress of the upload) is there anyway to do this
in asp.net? thanks

Nov 18 '05 #2
Thanks for Weston's informative suggestions.

Hi Brian,

Generaly we can use javascript function to display some waiting message on
the page when there is a long run task being processed at the serverside
when the page is posted back. Here is a simple demo page:

============aspx page===============
<HTML>
<HEAD>
<title>showwaitmsg</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function initialProgress()
{
document.getElementById("divProgress").innerText = "Uploading...";
window.setInterval("addDots();",500);
}

function addDots()
{
document.getElementById("divProgress").innerText =
document.getElementById("divProgress").innerText + ".";
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><INPUT id="fpMain" type="file" name="File1" runat="server">
<asp:Button id="btnUpload" runat="server" Text="Upload"></asp:Button>
</td>
</tr>
<tr>
<td>
<div id="divProgress" />
</td>
</tr>
</table>
</form>
</body>
</HTML>
==========code behind================
public class showwaitmsg : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnUpload;
protected System.Web.UI.HtmlControls.HtmlInputFile fpMain;

private void Page_Load(object sender, System.EventArgs e)
{
btnUpload.Attributes.Add("onclick","initialProgres s();");
}

#region Web
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnUpload_Click(object sender, System.EventArgs e)
{
try
{
if(fpMain.PostedFile != null)
{
string filename =
System.IO.Path.GetFileName(fpMain.PostedFile.FileN ame);
Response.Write("<br>" + filename + " is uploaded!");
System.Threading.Thread.Sleep(3* 1000);
}
}
catch(Exception ex)
{
Response.Write("<br>" + ex.Message);
}
}
}
=========================================

In addition, here are some other tech articles discussing the similar
topics:

#How to show progress in the client browser for a long-running ASP.NET page
http://support.microsoft.com/?id=837375

#DESIGN PATTERNS: Asynchronous Wait State Pattern in ASP.NET
http://msdn.microsoft.com/msdnmag/is...s/default.aspx
http://www.aspnetpro.com/NewsletterA..._l/asp200308bm
_l.asp

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ShaSha | last post by:
Hi, I am trying to upload XML files via HTTP to an HTTP server from java client instead of browser. On the HTTP server side, there is a Perl script that will be receiving the incoming file and files...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
0
by: Benjamin Bittner | last post by:
Hallo NG, ive searched a lot in some google groups, and found many threads, but nothing that helped me. Here is the scenario: I have an aspx page which loads a user control in page.onInit like...
6
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is...
4
by: Ashok | last post by:
Dear Friends, How to download a file from server to client local pc without user intervention ie without the save as popup window. Can you give me step by step. Thanks
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
4
by: AshishMishra16 | last post by:
HI friends, I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for...
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
2
by: Amzul | last post by:
hello all i search the net for upload picture secure code i fuond this code, and affter i changed it abit it looks like that : <?php class image_upload { var $tmp_image; var...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.