Created
April 17, 2014 18:37
-
-
Save andrewhavens/11003706 to your computer and use it in GitHub Desktop.
broken jQuery file upload example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Upload Documents</h1> | |
<form action="/documents" enctype="multipart/form-data" id="fileupload" method="post"> | |
<input type="file" name="document[attachment][]" multiple="multiple"> | |
<table> | |
<tbody id="files" class="files"></tbody> | |
</table> | |
</form> | |
<!-- jQuery 1.8.3 already included --> | |
<!-- The Iframe Transport is required for browsers without support for XHR file uploads --> | |
<script src="/javascripts/jquery.iframe-transport.js"></script> | |
<!-- javascript templating library --> | |
<script src="/javascripts/tmpl.min.js"></script> | |
<!-- The Load Image plugin is included for the preview images and image resizing functionality --> | |
<script src="/javascripts/load-image.min.js"></script> | |
<!-- The basic File Upload plugin --> | |
<script src="/javascripts/jquery.fileupload.js"></script> | |
<!-- The template to display files available for upload --> | |
<script id="template-upload" type="text/x-tmpl"> | |
{% for (var i=0, file; file=o.files[i]; i++) { %} | |
<tr class="template-upload fade"> | |
<td> | |
<span class="preview"></span> | |
</td> | |
<td> | |
<p class="name">{%=file.name%}</p> | |
<strong class="error text-danger"></strong> | |
</td> | |
<td> | |
<p class="size">Processing...</p> | |
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div> | |
</td> | |
<td> | |
{% if (!i && !o.options.autoUpload) { %} | |
<button class="btn btn-primary start" disabled> | |
<i class="glyphicon glyphicon-upload"></i> | |
<span>Start</span> | |
</button> | |
{% } %} | |
{% if (!i) { %} | |
<button class="btn btn-warning cancel"> | |
<i class="glyphicon glyphicon-ban-circle"></i> | |
<span>Cancel</span> | |
</button> | |
{% } %} | |
</td> | |
</tr> | |
{% } %} | |
</script> | |
<script> | |
$(function () { | |
$('#fileupload').fileupload(); // What are the minimum requirements to enable template support? | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a code sample that I was able to get working: