upload.xajax.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. include("../global.inc.php");
  3. require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';
  4. $xajax_upload = new Xajax();
  5. $xajax_upload -> registerFunction ('updateProgress');
  6. $xajax_upload -> processRequests();
  7. /**
  8. * This function updates the progress bar
  9. * @param div_id where the progress bar is displayed
  10. * @param upload_id the identifier given in the field UPLOAD_IDENTIFIER
  11. */
  12. function updateProgress($div_id, $upload_id, $waitAfterupload=false){
  13. $objResponse = new XajaxResponse();
  14. $ul_info = uploadprogress_get_info($upload_id);
  15. $percent = intval($ul_info['bytes_uploaded']*100/$ul_info['bytes_total']);
  16. if($waitAfterupload && $ul_info['est_sec']<2) {
  17. $percent = 100;
  18. $objResponse -> addAssign($div_id.'_label' , 'innerHTML', get_lang('UploadFile').' : '.$percent.' %');
  19. $objResponse -> addAssign($div_id.'_waiter_frame','innerHTML','<img src="'.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif" />');
  20. $objResponse -> addScript('clearInterval("myUpload.__progress_bar_interval")');
  21. }
  22. $objResponse -> addAssign($div_id.'_label' , 'innerHTML', get_lang('UploadFile').' : '.$percent.' %');
  23. $objResponse -> addAssign($div_id.'_filled' , 'style.width', $percent.'%');
  24. return $objResponse;
  25. }
  26. ?>