What I want to implement is by clicking “attach a file”, a file browser will be open to let user choose a file. I use jQuery to set onclick function of “attach a file”, and set the opacity of a fileuload control to be 0. So it is like display:none. But I don’t know how to get the file that user selected from fileupload control. Even don’t know what event should be capture in the process. I want to save the file in a hidden div, so I can use it in backend code. Any method?
UPDATE: OK, I think it’s better to describe my question more clearly. That is, how to get selected filename when you click open button in browser window? If in backend it is as easy as
string fileName=FileUpload1.PostedFile.FileName;
I want to get the fileName in client using jQuery. Since I will use same fileUpload control to select multiple files, I need to add the filename into a hidden div when the browser window closed. Any idea?
The file upload control renders as an INPUT of type file. If you retrieve its Value after change, it will hold the name of the file.