File Upload Progress Bar Rails
I followed the Railscasts episode (to get file uploads working on my site.Everything works the way the tutorial.
How to show percentage of upload in progress bar? Ask Question 0. I'm using Paperclip for image upload. RAILS ajax file upload with progress bar & drag-and-drop. File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.
Contents
- Requirements
- Browsers
Description
File Upload widget with multiple file selection, drag&drop support,progress bars, validation and preview images, audio and video for jQuery.
Supports cross-domain, chunked and resumable file uploads and client-sideimage resizing.
Works with any server-side platform (PHP, Python, Ruby on Rails, Java,Node.js, Go etc.) that supports standard HTML form file uploads.
Demo
Features
- Multiple file upload:
Allows to select multiple files at once and upload them simultaneously. - Drag & Drop support:
Allows to upload files by dragging them from your desktop or file manager anddropping them on your browser window. - Upload progress bar:
Shows a progress bar indicating the upload progress for individual files andfor all uploads combined. - Cancelable uploads:
Individual file uploads can be canceled to stop the upload progress. - Resumable uploads:
Aborted uploads can be resumed with browsers supporting the Blob API. - Chunked uploads:
Large files can be uploaded in smaller chunks with browsers supporting theBlob API. - Client-side image resizing:
Images can be automatically resized on client-side with browsers supportingthe required JS APIs. - Preview images, audio and video:
A preview of image, audio and video files can be displayed before uploadingwith browsers supporting the required APIs. - No browser plugins (e.g. Adobe Flash) required:
The implementation is based on open standards like HTML5 and JavaScript andrequires no additional browser plugins. - Graceful fallback for legacy browsers:
Uploads files via XMLHttpRequests if supported and uses iframes as fallbackfor legacy browsers. - HTML file upload form fallback:
Allows progressive enhancement by using a standard HTML file upload form aswidget element. - Cross-site file uploads:
Supports uploading files to a different domain with cross-site XMLHttpRequestsor iframe redirects. - Multiple plugin instances:
Allows to use multiple plugin instances on the same webpage. - Customizable and extensible:
Provides an API to set individual options and define callback methods forvarious upload events. - Multipart and file contents stream uploads:
Files can be uploaded as standard 'multipart/form-data' or file contentsstream (HTTP PUT file upload). - Compatible with any server-side application platform:
Works with any server-side platform (PHP, Python, Ruby on Rails, Java,Node.js, Go etc.) that supports standard HTML form file uploads.
Security
Please also read the SECURITY document for instructions on how tosecurely configure your Webserver for file uploads.
Setup
jQuery File Upload can be installed via NPM:
This allows you to include jquery.fileupload.js andits extensions via node_modules
, e.g:
The widget can then be initialized on a file upload form the following way:
For further information, please refer to the following guides:
Requirements
Mandatory requirements
- jQuery v1.6+
- jQuery UI widget factory v1.9+(included): Required for the basic File Upload plugin, but very lightweightwithout any other dependencies from the jQuery UI suite.
- jQuery Iframe Transport plugin(included): Required forbrowsers without XHR file upload support.
Optional requirements
- JavaScript Templates enginev3+: Used to render the selected and uploaded files for the Basic Plus UI andjQuery UI versions.
- JavaScript Load Image libraryv2+: Required for the image previews and resizing functionality.
- JavaScript Canvas to Blob polyfillv3+:Required for the image previews and resizing functionality.
- blueimp Gallery v2+: Used to display theuploaded images in a lightbox.
- Bootstrap v3+: Used for the demo design.
- Glyphicons Icon set used by Bootstrap.
Cross-domain requirements
Cross-domain File Uploadsusing theIframe Transport pluginrequire a redirect back to the origin server to retrieve the upload results. Theexample implementationmakes use ofresult.htmlas a static redirect page for the origin server.
The repository also includes thejQuery XDomainRequest Transport plugin,which enables limited cross-domain AJAX requests in Microsoft Internet Explorer8 and 9 (IE 10 supports cross-domain XHR requests).
The XDomainRequest object allows GET and POST requests only and doesn't supportfile uploads. It is used on theDemo to delete uploaded filesfrom the cross-domain demo file upload service.
Browsers
Desktop browsers
The File Upload plugin is regularly tested with the latest browser versions andsupports the following minimal versions:
- Google Chrome
- Apple Safari 4.0+
- Mozilla Firefox 3.0+
- Opera 11.0+
- Microsoft Internet Explorer 6.0+
Mobile browsers
The File Upload plugin has been tested with and supports the following mobilebrowsers:
- Apple Safari on iOS 6.0+
- Google Chrome on iOS 6.0+
- Google Chrome on Android 4.0+
- Default Browser on Android 2.3+
- Opera Mobile 12.0+
Extended browser support information
For a detailed overview of the features supported by each browser version andknown operating system / browser bugs, please have a look at theExtended browser support information.
Testing
The project comes with three sets of tests:
- Code linting using ESLint.
- Unit tests using Mocha.
- End-to-end tests using blueimp/wdio.
To run the tests, follow these steps:
- Start Docker.
- Install development dependencies:
- Run the tests:
Support
This project is actively maintained, but there is no official support channel.
If you have a question that another developer might help you with, please posttoStack Overflowand tag your question with blueimp jquery file upload
.
Javascript File Upload Progress
License
Released under the MIT license.
Ajax File Upload Progress Bar
I'm using jquery-fileupload-rails
Gem for uploading the Image in my application. Here is the code:
And in .js file:
Every thing works fine but after image upload, the progress bar does not remove. How can remove bar after upload ?
1 Answer
Instead of done
callback add stop
callback in your js file