Details of fileupload filename and fileupload postedfile. filename Uploaded By Asp.net
You may be familiar with ASP. NET file upload and use the commonly used control fileupload.
Main steps:
1. Determine if it is legal
2. Obtain the file path (including the complete directory path, and you may need to modify the file name)
3. Save the file
For example:
Fileupload1.saveas (server. mappath ("Upload") + "\" + fileupload1.filename );
It is estimated that the difference between fileupload1.filename and fileupload1.postedfile. filename cannot be clarified by beginners.
In fact,Fileupload1.Filename is the name of the uploaded file,Fileupload1.Postedfile. filename the uploaded file name includes its complete path.
View Source
Print?
1 |
Label1.text = fileupload1.filename; |
2 |
Label2.text = fileupload1.postedfile. filename; |
Result In Firefox:
Results in IE6 +:
The results in ie9 are the same as those in Firefox.
That is, fileupload1.postedfile. filename only obtains the name of the uploaded file.
Modify:
View Source
Print?
1 |
Label1.text = fileupload1.filename; |
2 |
Label2.text = fileupload1.postedfile. filename; |
3 |
Label3.text = path. getfilename (fileupload1.postedfile. filename ); |
UsePath. getfilename (fileupload1.postedfile. filename );To get the file name,
The path uses thisString strdr = request. physicalapplicationpath + "\\";
In this way, all browsers are compatible.
For beginners, please pay attention to these details.
Just D0! T .,.