Advertisement
Guest User

Django with jQuery File Upload

a guest
Jun 11th, 2012
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.35 KB | None | 0 0
  1. <!--
  2. /*
  3. * Django with jQuery File Upload Plugin Demo
  4. * https://github.com/garmoncheg/django_multiuploader_demo/
  5. *
  6. * Copyright 2011, Iurii Garmash
  7. * http://garmoncheg.blogspot.com/
  8. */
  9. -->
  10. {% load verbatim %}
  11. <meta charset="utf-8">
  12.  
  13. <link rel="stylesheet" href="/script/backend/jqueryui/css/snap_orange/jquery-ui-1.8.18.custom.css" id="theme">
  14.  
  15.  
  16. <link rel="stylesheet" href="/script/backend/jquery_multiuploader/styles/jquery.fileupload-ui.css">
  17.  
  18. <div id="fileupload">
  19.     <form action="{% url multi %}" method="POST" enctype="multipart/form-data" style="margin: 0 0 0px;">
  20.         <div class="fileupload-buttonbar button_bar">
  21.             <span class="fileinput-button">
  22.                 <span> Add files</span>
  23.                 <input type="file" multiple="" name="files[]">
  24.             </span>
  25.             <button type="submit" class="start"> Start upload</button>
  26.             <button type="reset" class="cancel"> Cancel upload</button>
  27.             {% comment %}<button type="button" class="delete"> Delete files</button>{% endcomment %}
  28.         </div>
  29.     </form>
  30.     <div class="fileupload-content drop_area">
  31.         <p class="help-block"><small><em>Drag and drop your files here or click on the "Add files" button! The maximum filesize allowed is {{ MAXIMUM_FILE_SIZE }} MB.</em></small></p>
  32.         <table class="files"></table>
  33.         <div class="fileupload-progressbar"></div>
  34.     </div>
  35. </div>
  36. <div id="help" style="color:gray;">
  37.     <h2>
  38.         <p>You can select Multiple files at once using Ctrl(Win) or Command(Mac), or you can drag'n'drop your files on this form.</p>
  39.     </h2>
  40. </div>
  41. {% verbatim %}
  42.  
  43. <script id="template-upload" type="text/x-jquery-tmpl">
  44.     <tr class="template-upload{{if error}} ui-state-error{{/if}}">
  45.         <td class="preview"></td>
  46.         <td class="name">${name}</td>
  47.         <td class="size">${sizef}</td>
  48.         {{if error}}
  49.             <td class="error" colspan="2">Error:
  50.                 {{if error === 'maxFileSize'}}The file is too big! The maximum file size allowed is {% endverbatim %}{{ MAXIMUM_FILE_SIZE }} MB!{% verbatim %}
  51.                 {{else error === 'minFileSize'}}File is too small
  52.                 {{else error === 'acceptFileTypes'}}Filetype not allowed
  53.                 {{else error === 'maxNumberOfFiles'}}Max number of files exceeded
  54.                 {{else error === 'maxFileName'}}The file's name exceeds the maximum allowed.
  55.                 {{else}}Oops! something went wrong while performing the operation! Please try again or refresh the page if you experience the same problem. Error is: "${error}"
  56.                 {{/if}}
  57.             </td>
  58.         {{else}}
  59.             <td class="progress" style="background-color: none; background-image: none; box-shadow: none;"><div></div></td>
  60.             <td class="start"><button class="btn btn-primary"><i class="icon-upload icon-white"></i>Start</button></td>
  61.         {{/if}}
  62.         <td class="cancel"><button class="btn btn-warning"><i class="icon-ban-circle icon-white"></i>Cancel</button></td>
  63.     </tr>
  64. </script>
  65. <script id="template-download" type="text/x-jquery-tmpl">
  66.     <tr class="template-download{{if error}} ui-state-error{{/if}}">
  67.         {{if error}}
  68.             <td></td>
  69.             <td class="name">${name}</td>
  70.             <td class="size">${sizef}</td>
  71.             <td class="error" colspan="2">Error:
  72.                 {{if error === 1}}File exceeds upload_max_filesize (php.ini directive)
  73.                 {{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)
  74.                 {{else error === 3}}File was only partially uploaded
  75.                 {{else error === 4}}No File was uploaded
  76.                 {{else error === 5}}Missing a temporary folder
  77.                 {{else error === 6}}Failed to write file to disk
  78.                 {{else error === 7}}File upload stopped by extension
  79.                 {{else error === 'maxFileSize'}}The file is too big! The maximum file size allowed is {% endverbatim %}{{ MAXIMUM_FILE_SIZE }} MB!{% verbatim %}
  80.                 {{else error === 'minFileSize'}}File is too small
  81.                 {{else error === 'acceptFileTypes'}}Filetype not allowed
  82.                 {{else error === 'maxNumberOfFiles'}}Max number of files exceeded
  83.                 {{else error === 'uploadedBytes'}}Uploaded bytes exceed file size
  84.                 {{else error === 'emptyResult'}}Empty file upload result
  85.                 {{else error === 'maxFileName'}}The file's name exceeds the maximum allowed. Shortern the file name and try again! Maximum allowed is ${extra} characters long.
  86.                 {{else}}Oops! something went wrong while performing the operation! Please try again or refresh the page if you experience the same problem. Error is: "${error}"
  87.                 {{/if}}
  88.             </td>
  89.         {{else}}
  90.             <td class="preview">
  91.                 {{if thumbnail_url}}
  92.                     <a href="${url}" target="_blank"><img src="${thumbnail_url}"></a>
  93.                 {{/if}}
  94.             </td>
  95.             <td class="name">
  96.                 <a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>
  97.             </td>
  98.             <td class="size">${sizef}</td>
  99.             <td colspan="2"></td>
  100.         {{/if}}
  101.         <td class="delete">
  102.             <button data-type="${delete_type}" data-url="${delete_url}">Delete</button>
  103.         </td>
  104.     </tr>
  105. </script>
  106. {% endverbatim %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement