Ignore:
Timestamp:
Jun 29, 2010, 8:42:11 PM (14 years ago)
Author:
plg
Message:

merge r6624 from branch 2.1 to trunk

bug 1747 fixed: some checks were added to verify the upload will fail for a
too big size or if the upload has failed for a too big size (test on
upload_max_filesize and post_max_size)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes/default/template/photos_add_direct.tpl

    r6622 r6625  
    5050  }
    5151
     52  function humanReadableFileSize(bytes) {
     53    var byteSize = Math.round(bytes / 1024 * 100) * .01;
     54    var suffix = 'KB';
     55
     56    if (byteSize > 1000) {
     57      byteSize = Math.round(byteSize *.001 * 100) * .01;
     58      suffix = 'MB';
     59    }
     60
     61    var sizeParts = byteSize.toString().split('.');
     62    if (sizeParts.length > 1) {
     63      byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2);
     64    }
     65    else {
     66      byteSize = sizeParts[0];
     67    }
     68
     69    return byteSize+suffix;
     70  }
     71
    5272  if ($("select[name=category] option").length == 0) {
    5373    $('input[name=category_type][value=existing]').attr('disabled', true);
     
    91111var pwg_token = '{$pwg_token}';
    92112var buttonText = 'Browse';
     113var sizeLimit = {$upload_max_filesize};
    93114
    94115{literal}
     
    109130    'fileDesc'       : 'Photo files (*.jpg,*.jpeg,*.png)',
    110131    'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG',
     132    'sizeLimit'      : sizeLimit,
    111133    'onAllComplete'  : function(event, data) {
    112134      if (data.errors) {
     
    119141    onError: function (event, queueID ,fileObj, errorObj) {
    120142      var msg;
    121       if (errorObj.status == 404) {
    122         alert('Could not find upload script.');
    123         msg = 'Could not find upload script.';
    124       }
    125       else if (errorObj.type === "HTTP") {
    126         msg = errorObj.type+": "+errorObj.status;
     143
     144      if (errorObj.type === "HTTP") {
     145        if (errorObj.info === 404) {
     146          alert('Could not find upload script.');
     147          msg = 'Could not find upload script.';
     148        }
     149        else {
     150          msg = errorObj.type+": "+errorObj.info;
     151        }
    127152      }
    128153      else if (errorObj.type ==="File Size") {
    129         msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
     154        msg = "File too big";
     155        msg = msg + '<br>'+fileObj.name+': '+humanReadableFileSize(fileObj.size);
     156        msg = msg + '<br>Limit: '+humanReadableFileSize(sizeLimit);
    130157      }
    131158      else {
    132         msg = errorObj.type+": "+errorObj.text;
     159        msg = errorObj.type+": "+errorObj.info;
    133160      }
    134161
     
    240267  <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p>
    241268</fieldset>
    242 <p><a href="">{'Add another set of photos'|@translate}</a></p>
     269<p><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p>
    243270{else}
    244271
     
    251278</div>
    252279
    253 <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties">
     280<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties">
    254281    <fieldset>
    255282      <legend>{'Drop into category'|@translate}</legend>
Note: See TracChangeset for help on using the changeset viewer.