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 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- android studio - unresolved reference comes out in kotlin
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- python - importerror: cannot import name md5 error cannot be resolved