INPUT Type="FILE" - Just want to get the file name and path as string

K

kevin

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\videos), 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.PostedFile.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
 
K

Karl Seguin [MVP]

It does. But short of using an ActiveX control, I don't think you'll find a
workaround. Even JavaScript is extremely limited in what it can help you
with - namely because of potential security issues.

Karl
 
N

Nicole Calinoiu

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.HtmlControls;

[assembly: TagPrefix("Bordecal.Web.UI.HtmlControls", "bordecal")]

namespace Bordecal.Web.UI.HtmlControls
{
[ValidationProperty("Value")]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
public class HtmlInputFileName : HtmlInputText
{
public HtmlInputFileName()
: base("file")
{
}
}
}

The above control would expose the selected file name via its Value
property.
 
B

bruce barker \(sqlwork.com\)

don't use the file control. have a page that builds a list doing a
directory.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top