Skip to content

A drag and drop html5 javascript file uploader. Upload multiple files at a time from your computer or a mobile device.

Notifications You must be signed in to change notification settings

thedeepwoodsbrigade/file-uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileUploader

An HTML5 and javascript file uploader that supports drag and drop, as well as file input, uploading. Written in coffeescript.

Usage

With the following html

<html>
  <head>
    <title>Drop test</title>
    <style type='text/css' src='file-uploader.css'></style>
  </head>
  <body>
    <div class='drop-area'></div>
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
    <script type='text/javascript' src='file-uploader.js'></script>
  </body>
</html>

And a little bit of js magic

new FileUploader('.drop-area', '/files/');

A party is born.

FileUploader takes a minimum of two arguments:

  1. A css selector for the area you want to use for the uploader
  2. A url to upload the files to

By default the uploader will use 'POST' as the method used in the ajax call.

Extras

If you add a data-file-uploader-content attribute to the node you are going to use, FileUploader will append it into the results area for you.

There is also the beginnings of support for hooking into the ajax call. I've added an options hash for a third argument. That hash currently supports the following options:

  • method: POST, PUT, etc.
  • before: a function to run before the ajax request is triggered
  • complete: a function to run after the ajax request has been completed

Browser Support

This has been tested on the latest platforms for:

  1. Desktop
  2. Firefox
  3. Chrome
  4. Safari
  5. Mobile
  6. IOS 6.1
  7. Android 4.x

More testing needs to be completed. This should work on any webkit based browser and any browser that supports the FormData javascript object.

Requirements

  1. jQuery
  2. Some basic javascript knowledge

Roadmap

  1. Add automatic results area injection (Done)
  2. Add automatic file input injection (Done)
  3. Get rid of dependency on jQuery
  4. Add options for overriding the ajax submit method
  5. Add options for overriding error, complete, and success callbacks (Support for ajax before and complete are implemented)
  6. Setup automated node compilation of coffeescript to javascript
  7. Setup proper testing
  8. Check support for IE

Contributing

Feel free to make changes. Fork this project and have at. If you make anything you'd like to give back just make a pull request.

Compiling

If you have nodejs installed you can npm install to get all the dependencies. After that run:

./node_modules/coffee-script/bin/coffee -c -o lib src

The compiled, but unminified js, will be stored in the lib directory. Just copy to wherever you need to use it.

About

A drag and drop html5 javascript file uploader. Upload multiple files at a time from your computer or a mobile device.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published