Lynx
Lynx

Reputation: 257

how to get/read file name from FileUpload control?

how to get or read the file name from FileUpload control when borwse button clicked and a file is selected. for example, when browse button clicked, i can browse a file from any location in my computer, for example select video file name al.avi in C://video/al.avi. so how can i get and read the video's name and display it in label control.

Upvotes: 0

Views: 12930

Answers (1)

nunespascal
nunespascal

Reputation: 17724

When you PostBack to the server you get the data in the file as well as the file name in the FileUpload control.

var fileName = FileUpload1.PostedFile.FileName;

This will give you the fileName part 'al.avi'. You can display this in a label.

Here is a FileUpload example to get you started.

Upvotes: 5

Related Questions