Ain ASP has no component upload class. I dare not boast about how perfect it is, but it can achieve basic functions, including extracting form data, uploading to different folders, saving to the database (uploading and saving forms can be done at the same time), and limiting upload extensions. , limit the upload size, select the file saving type (randomly named original file name and time), etc.!
This class can completely save user information, including the form with the same name (saved with, as the delimiter like request.form), and the client path of the file field.
After processing the data, the program will provide two methods-----files and forms. Through these two methods, files can be saved and information can be read, and they can be called
The GetBytes method of the fileaction class obtains the binary data of the file and can save this data to the database (the author does not recommend saving binary data to the database.
will affect database performance).
The biggest advantage of this type is more in the multi-file upload, that is, you can use a loop to save all files to the same directory, and you can save them to different directories individually. It is quite flexible and completely free from the constraints of any other objects. And you can choose the saving method independently - save with the original file name or save with the file name (time + random number) automatically generated by the program. Features of this category:
• Pursue simplicity as much as possible and reduce redundant code
• Comprehensive storage of information submitted by customers (ordinary forms, file field values, same form values)
• Accurately obtain error information during uploads
• You can choose the file saving method (save with original file name or save with new file name, the new file name is time + random number group
• The file saving function is simple, easy to call, and flexible (the saving path and saving method can be changed at any time)
• At the same time, the binary form of the file can be obtained, so that binary data can be saved to the database.
• Flexible use of this class allows simultaneous editing of form data and files (this is unachievable with general classes)
• It’s up to everyone to discover more uses...
• There are several very simple examples in the Demo. If you can master these examples, you will be able to use this category flexibly. Update date: 2009-7-9
1. Further optimize the class to reduce resource consumption.
2. Add the function of automatically creating directories that do not exist.
3. Delete a simple file saving class and keep only a simple file saving function.
Expand