The HtmlInputFile control sets the form's enctype to "multipart/form-data"
in their OnPreRender methods, which is what causes the file to be uploaded.
You could avoid this by creating your own file name control by subclassing
the HtmlInputText control:
using System;
using System.Security .Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.H tmlControls;
[assembly: TagPrefix("Bord ecal.Web.UI.Htm lControls", "bordecal")]
namespace Bordecal.Web.UI .HtmlControls
{
[ValidationPrope rty("Value")]
[AspNetHostingPe rmission(Securi tyAction.Inheri tanceDemand, Level =
AspNetHostingPe rmissionLevel.M inimal)]
[AspNetHostingPe rmission(Securi tyAction.LinkDe mand, Level =
AspNetHostingPe rmissionLevel.M inimal)]
public class HtmlInputFileNa me : HtmlInputText
{
public HtmlInputFileNa me()
: base("file")
{
}
}
}
The above control would expose the selected file name via its Value
property.
<ke***@webpagec oncepts.comwrot e in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Hi, I am trying to create a page so the user can browse the network,
select a file and have that file name (text) inserted into our sql DB
so I can build the hyperlink path later on.
Here's what seems to be the problem. These are video files and are
enormous with long crazy names so trying to hand type the file name in
a text box is not an option. So I'm using an Input "file" control so
when the user browses out onto the network (Z:\drive\video s), gets the
file path into the Input file text box and then hits the insert control
to process the filename it bombs because the files are too huge
(100+MB). I just want to get the name to a string and not actually get
the file.
MyFile.PostedFi le.FileName is great but it seems to have to process the
file and not just give me the text of the file after I browsed.
If this makes any sense, any help would be great. Thanks K