Details of fileupload filename and fileupload postedfile. filename Uploaded By Asp.net

Source: Internet
Author: User
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 .,.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.