Coder Social home page Coder Social logo

mirzaafzal / jquery-upload-progress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drogus/jquery-upload-progress

1.0 1.0 0.0 85 KB

Upload progress bar working with apache, nginx and lighttpd upload progress modules

Home Page: http://drogomir.com/blog/2008/6/30/upload-progress-script-with-safari-support

jquery-upload-progress's Introduction

It can be used with apache upload progress module, nginx upload progress module or lighttpd, read more here: http://drogomir.com/blog/2008/6/18/upload-progress-bar-with-mod_passenger-and-apache

Usage:

some html:
     <form id="upload" enctype="multipart/form-data" action="index.html" method="post">
        <input name="file" type="file"/>
        <input type="submit" value="Upload"/>
      </form>
		
      <div id="uploading">
        <div id="progress" class="bar">
          <div id="progressbar">&nbsp;</div>
          <div id="percents"></div>
        </div>
      </div>

then some css:
  
  .bar {
    width: 300px;
  }
  
  #progress {
    background: #eee;
    border: 1px solid #222;
    margin-top: 20px;
  }
  #progressbar {
    width: 0px;
    height: 24px;
    background: #333;
  }

and a bit of javascript:

$(function() {
    $('form').uploadProgress({
		/* scripts locations for safari */
		jqueryPath: "../lib/jquery.js",
		uploadProgressPath: "../jquery.uploadProgress.js",
    /* function called each time bar is updated */
		uploading: function(upload) {$('#percents').html(upload.percents+'%');},
		/* selector or element that will be updated */
		progressBar: "#progressbar",
		/* progress reports url */
		progressUrl: "/progress",
    /* how often will bar be updated */
		interval: 2000
    });
});

If you need to update the progress bar from a different domain or subdomain, liek if your upload server is different from your normal web server, you can try the JSON-P protocol, like this:
$(function() {
    $('form').uploadProgress({
		/* scripts locations for safari */
		jqueryPath: "../lib/jquery.js",
		uploadProgressPath: "../jquery.uploadProgress.js",
    /* function called each time bar is updated */
		uploading: function(upload) {$('#percents').html(upload.percents+'%');},
		/* selector or element that will be updated */
		progressBar: "#progressbar",
		/* progress reports url in a different domain or subdomain from caller */
		progressUrl: "uploads.somewhere.com/progress",
    /* how often will bar be updated */
		interval: 2000,
		/* use json-p for cross-domain call */
		dataType: 'jsonp'
    });
});

defaults:

interval: 2000
progressBar: "#progressbar"
progressUrl: "/progress"
start: function() {}
uploading: function() {}
complete: function() {}
success: function() {}
error: function() {}
uploadProgressPath: '/javascripts/jquery.js'
jqueryPath: '/javascripts/jquery.uploadProgress.js'
dataType: 'json'

jquery-upload-progress's People

Contributors

drogus avatar deadprogram avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.