In actual programming,I often encounter the function of uploading files and displaying upload progress.For this purpose,This article will introduce the file upload function with progress display without using flash or any plug-in for uploading files.
Basic function:implement file upload function with progress bar
Advanced features:Multiple file uploads via drag and drop
html5 provides a standard way to access local files-file api specifications,File information can be accessed by calling the file api,You can also use the client to verify the type and size of the uploaded file.
This specification contains the following interfaces to use the file:
file interface:has "read permissions" for a file, can get the file name,Type, size, etc.
filelist interface:refers to a list of individually selected files,It can be displayed in the user interface for selection byor drag and drop.
xmlhttprequest2 is the unknown hero of html5,xhr2 is roughly the same as xmlhttprequest,But also added many new features,as follows:
1. Added upload/download binary data
2. Added the progess (progress bar) event during the upload process, which contains multiple parts of information:
total:an integer value that specifies the total number of bytes of data to be transmitted.
loaded:an integer value that specifies the bytes to upload.
lengthcomputable:The bool value is used to detect whether the uploaded file size can be calculated.
3. Cross-resource sharing request
These new features make ajax and html5 work well together.Makes file upload very easy,No longer need to use flash player, external plugin or html's
- php + ajax example of image file upload function
- A simple jQuery plugin ajaxfileuploadjs to implement ajax upload file example
- How to implement a progress bar based on HTML5 Ajax file upload (jquery version)
- js HTML5 Ajax implement file upload progress bar function
- php + html5 + ajax method for uploading pictures
- Previewable multi-picture Ajax upload based on HTML5
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- xcode - pod install [!] no `podfile 'found in the project directory
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file