Atitit File Upload Architecture Design Implementation Mechanism Solution Practice Java PHP c#.net js javascript c + + python
1. Upload a few requirements 2
1.1. Local Preview 2
1.2. 2 No Refresh 2
1.3. 3 Progress Display 2
1.4. Breakpoint Continuation 2
1.5. Cross BS CS 2
1.6. With progress bar 2
1.7. Finish prompting animation effect ... 2
2. Standardize API Properties 2
3. Implementation principle using the FormData object, you can use a series of key-value pairs to simulate a complete form, and then use XMLHttpRequest to send the "form". 3
4. If you need to display a progress bar, real-time display of File upload progress requires the use of AJAXJ technology. Up to an IFRAME in the blackheads. Working principle of its actual is in the process of uploading files at the same time, the upload progress information such as the total length of the file, the number of uploads, the transfer rate is written to the session, the client browser using AJAX technology to open a new independent process from the session to get upload progress information, and real-time display, Ajax technology can not refresh the page to get server data. Session can be seen as server memory and can be used to store a small amount of customer information. 3
5. Implementation of PHP 4
5.1. Java vs. PHP differences 4
6. Atiupload 5
7. Reference 5
1. Upload a few requirements
1.1. Local preview
1.2.2 No Refresh
1.3.3 Progress Display
1.4. Continuation of the breakpoint
1.5. Cross BS CS
1.6. With progress bar
1.7. Complete the ToolTip animation effect.
Author:: Nickname: Old Wow's paw (full name:: Attilax Akbar al Rapanui Attilaksachanui) Kanji name: Ayron, email:1466519819@qq.com
Reprint please indicate source: http://www.cnblogs.com/attilax/
2. Standardize API Properties
Fld Specifying a textbox name for backfilling
CallbackQ11 Default Answer function
Callback Specifying a callback function
3. Implementation principle using the FormData object, you can use a series of key-value pairs to simulate a complete form, and then use XMLHttpRequest to send the "form".
This is a class provided by XMLHttpRequest 2.0.
You can also use jquery to send FormData, but you have to set the relevant options correctly:
4. If you need to display a progress bar, real-time display file upload progress requires the use of AJAXJ technology. Up to an IFRAME in the blackheads. Working principle of its actual is in the process of uploading files at the same time, the upload progress information such as the total length of the file, the number of uploads, the transfer rate is written to the session, the client browser using AJAX technology to open a new independent process from the session to get upload progress information, and real-time display, Ajax technology can not refresh the page to get server data. Session can be seen as server memory and can be used to store a small amount of customer information.
Upload Listener commons-fileupload version 1.2 supports upload monitoring, only need to implement a listener, and add it to the upload component. The listener needs to implement its Progresslistener
5. Implementation of PHP
This temporary copy of the file disappears at the end of the script. To save the uploaded file, we need to copy it to another location:
if (isset ($_post[' upload ')) {
Var_dump ($_files);
The third parameter is "true" to indicate that you can create a multilevel directory, iconv prevent Chinese directory garbled
$res =mkdir (Iconv ("UTF-8", "GBK", $path), 0777,true);
$f =dirname (__file__). ' /up_tmpx2/'. Time (). JPG ';
mkdir (DirName ($f), 0777,true); Move_uploaded_file ($_files[' upfile ' [' tmp_name '], $f);
Header (' location:test.php ');
Exit
5.1. Different points of Java and PHP
PHP needs to move memory file to temp file
Direct Stream writes to Jva
6. Atiupload
7. Reference
Atitit.ajax upload file Implementation principle and design-attilax column-Blog channel-CSDN.NET.htm
Atitit.jquery Ajax HTML5 uploading image files