Selecting a file client side

  • Thread starter Thread starter Dave56
  • Start date Start date
D

Dave56

Hi.

I know how to use <input type=file runat=server> to upload a file to the
webserver.
However, my files are 2gb and I don't want to up load them.

What I would like to be able to do is to just get the filename of the file
the user selected (for example "c:\temp\movie.wmv").
I also want validation that requires the selection of a .wmv file.

What is the best way to do that?

Thanks
 
Add this to the HTML designer page

<INPUT id="MyFile" type="file" name="MyFile" runat="server">

Then you can refer to the 'MyFile' object in the code behind.

MyFile.PostedFile.FileName
 
Thanks,

I have tried that, but .net is automatically setting the Enctype property of
the HtmlForm to "multipart/form-data".
So it is trying to upload the file.

MSDN says:
When uploading large files, use the maxRequestLength attribute of the
<httpRuntime> element to increase the maximum allowable file size. A DNS
error is generated in the browser when the file exceeds the specified size.

Since the file is huge I get this error.

Besides, I just want the name of the file and not to actually have it
uploaded.

Is there any way to get around this?

Dave56
 
He said he didn't want to upload them. If you put an input type=file HTML
element in a page, and the user browses to a file and submits the form, the
file will be uploaded, regardless of whether the app saves it or not. With a
2GB file, this could take quite a while to run.

Unfortunately, there is no HTML element for simply picking a file name.
There are a couple of alternatives:

1. Use the input type=file to have the user browse for the file. On submit,
copy the value from the input type=file element, and put it into a hidden
form field. Then remove it from the input type=file field, so that it
doesn't upload.
2. Write a client-side ActiveX control or Java applet to do this.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top