ASP component-less Upload? From Principle analysis to practice)
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Day 5: get the file unit
What we want to do today is to get the file content in a more interesting way. In fact, let's look at the data we want to process and the processing of the text unit the day before yesterday.
To clearly distinguish between files and text units, we use ourRequest. file (index) to correspond to ourRequest. form (index) of text units ). Of course, because the information we need for files is different from the text, this time we will not get FormElement, but a new object FileElement.
The differences between the file unit and the text unit on the raw data are poor:
1. The first line has an additional filename = "xxx" module;
2. The second line is used to indicate contentType.
The target information is different. Therefore, the obtained object FileElement is different from the FormElement object:
1. The count attribute is not required (checkbox does not exist );
2. Item (index) is not required (same as above, checkbox does not exist );
3. A ContentType attribute is required;
4. A FilePath attribute is required;
5. A FileName attribute is required;
6. A Size attribute is required;
7. Because binary is required, there is no need to convert binary => strings;
8. Because binary is required, it is more appropriate to change the attribute Value to Data.
In addition, UploadRequest should also add the Files attribute, Form (index) method, and m_dicFiles members. Now, we will expand it:
A. UploadRequest (designed above, expanded here)
This class corresponds to the request object.
RawData obtains raw data to facilitate [read-only] check.
Forms returns a counter with the count attribute,
You can use outRequest. Forms. Count to obtain the number of text form fields [read-only].
Files Gets a counter with the count attribute,
You can use outRequest. Files. Count to obtain the number of file form fields [read-only].
Form (index) can be used to retrieve text form fields using numbers or text. It is similar to request. Form.
It returns a FormElement object.
File (index) can be used to retrieve the File form field using numbers or text. It returns a FileElement object.
It can be seen as the embodiment of a single file domain. This class can be used to obtain detailed file information, such as name, data, path, filename, contentType, and size.
The Name of the file domain. Is xxx in <input type = file name = xxx>
The content of the Data file. Binary string
ContentType of the file field
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.