RE: FileUpload - keep the filename



Hi Dave,

As for the fileupload control, it won't persist the filename after the post
in which the file stream is uploaded. This is because the file stream only
exists in the postback of the uploading post, after that , no filestream
exists in the request, so there is no reason to persist the filename any
longer. This also confirm to the html <input type="file" ...> element's
natural behavior. BTW, if you do need to persist the filename(of the
latest uploaded file), you can consider manually store it in the fileupload
control's attributes colleciton for sequential use. For example:

======================
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (fu1.HasFile && fu1.FileName != null)
{
fu1.Attributes["filename"] = fu1.FileName;
}
}
=======================

then, in later postback, we can access the value through
fu1.Attriburtes["filename"]

Hope this helps you.


Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.











.



Relevant Pages

  • RE: FileUpload - keep the filename
    ... The problem we have is users click that button, see the filename disappear, ... in which the file stream is uploaded. ... exists in the postback of the uploading post, after that, no filestream ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: FileUpload name goes away
    ... As for the fileupload control, it will only hold the filename at the post ... in which the client-side submit the actual filestream. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: IO Exception in ASP .NET
    ... try to upload ur image in the server and save in the db only the filename ... > i creat a temperory file stream and read the bytefrom db ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IE8 Breaking fixes with the Input File control
    ... the "Include local directory path when uploading files" ... URLAction has been set to "Disable" for the Internet Zone. ... We were relying on javascript to pull the filename from an input ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: uploaded file name
    ... > After uploading the file, I would like to preview the filename and the ... > original path uploaded from the client side and not what is now ... The local filepath is immaterial IMO (whereas the filename is useful).. ...
    (comp.lang.php)

Loading