1. Unable to display the upload button under IIS
Note that in JS, the path must be written in the following way:
Flash_url: '@ URL. Content ("~ /Common/swfupload/swfupload.swf ")',
Button_image_url: '@ URL. Content ("~ /Common/swfupload/testimagenotext_65x29.png ")',
If you write
Button_image_url: '/common/swfupload/testimagenotext_65x29.png ")',
Debugging in iisexpress is successful, but an error occurs when running in IIS because the former will add the virtual path, and the latter will not.
The final problem is: 1. the upload button is not displayed; 2. Of course, you cannot click the open file dialog box because the SWF file cannot be loaded.
Ii. Writing the upload path:
Suppose we use the upload method of uploadcontroller to process the upload, then:
1. The parameters must be consistent. Of course, we can not set the parameters. We only use request. files to obtain the transmitted files.
2. The path is consistent with flash_url, and URL. Content is also used. Of course, URL. Action is also available.
Iii. BackgroundCodeWriting:
For one file, for multiple files
Iv. File Size Limit
V. Differences between file and swfupload:
In principle, swfupload reads files locally, and we can get the local progress through Js. Therefore, we know how much data has been transferred before it reaches the server.
The file control is the progress only after the entire file is transferred to the server. Of course, there are some special server-side methods that can parse the request content to get the "Number of arrived"
Therefore, swfupload polls the local progress through Js.
Of course, if the server processing time is long, you can also use local js to poll a progress value on the server.
Therefore, you can unify the style of the progress bar. server-side processing usually includes: 1. Save the arriving request (including the entire file) to the disk; 2. If the request is an import operation, then add it to the database.
This is a situation such as Excel. If a file is transmitted to the database in the form of a file, you do not need to save the file operation. It is only applicable to stream processing.
6. Consider disabling Java on the client or not installing flash.
VII. encapsulated upload function:
In fact, the ideal way to upload a single file is to provide a button. After selecting a file, the file name, uploading, And a progress bar appear at the rear or bottom of the button. Of course, it can display the upload time, the remaining time, and the best upload speed.
After the upload is complete, keep the information and "Upload successful". The next time you select a file, repeat this action.
If the client disables JS, the file control is used instead and the progress is not displayed. At this time, nothing can be done through Js.
If the client can use JS, But Flash is not installed, you can use a rolling GIF image to roughly indicate that the upload is in progress.
For multiple files, the method is similar. In general, the demo on the swfupload official website includes JS files such as file queue and speed, which can be used after modification.
Asp.net MVC can be encapsulated in two ways:
1. encapsulated as htmlhelper
2. A unique upload action is provided globally and called everywhere.