Forums / Developer / File Upload Progress Bar

File Upload Progress Bar

Author Message

scrieler _

Monday 25 August 2008 6:00:30 am

heya ez community!

I am using ez 4.0
I have a module to upload a zip file and want to have a progress bar for it.
I have found this: http://talks.php.net/show/afup06/22

Can u help me how to run this?

-------------------------------------------------------------------------
In my pagelayout I have
--------------------------------------------------------------------------

<script type="text/javascript" src={'javascript/yui/yahoo.js'|ezdesign}></script>
<script type="text/javascript" src={'javascript/yui/connection.js'|ezdesign}></script>
<script type="text/javascript">
{literal}
var fN = function callBack(o) { 
 var result = document.getElementById('result');
 result.innerHTML='<pre>'+o.responseText+'</pre>';
}
var callback = { success:fN, upload:fN }
function postForm(target,formName,up) {
  YAHOO.util.Connect.setForm(formName,up);
  YAHOO.util.Connect.asyncRequest('POST',target,callback);
}
{/literal}
</script>

-------------------------------------------------------------------------
in my upload.tpl
-------------------------------------------------------------------------


<form enctype="multipart/form-data" id="upload_form" action="" onsubmit="postForm('/test-bestellung/upload','upload_form',1); return false;" method="POST">


{def $user=fetch( 'user', 'current_user' )}
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="{ezhttp( 'eZUserLoggedInID', 'session' )}" />

and this


<script>
{literal}
var fP = function callBack(o) {
 var resp = eval('(' + o.responseText + ')');
 if(!resp['done']) { 
  if(resp['total']) {
   var pct = parseInt(100*(resp['current']/resp['total']));
   document.getElementById('pbar').style.width = ''+pct+'%';
   document.getElementById('ppct').innerHTML = " "+pct+"%";
   document.getElementById('ptxt').innerHTML = resp['current']+" of "+resp['total']+" bytes";
  }
  setTimeout("update_progress()",500);
 } else if(resp['cancel_upload']) {
  txt="Cancelled after "+resp['current']+" bytes!"; 
  document.getElementById('ptxt').innerHTML = txt;
  setTimeout("progress_win.hide();window.location.reload(true);",2000);
 }
}

var pcallback = { success:fP }

function update_progress() {
 progress_key = document.getElementById('progress_key').value;
 YAHOO.util.Connect.asyncRequest('GET','/test-bestellung/upload?progress_key='+progress_key, pcallback);
}

var progress_win;

function postForm(target,formName) {
 YAHOO.util.Connect.setForm(formName,true);
 YAHOO.util.Connect.asyncRequest('POST',target,callback);
 progress_win = new YAHOO.widget.Panel(...);
 update_progress();
}
{/literal}
</script>
 <div id="progress_win"> 
    <div class="hd"></div> 
    <div class="bd"></div> 
    <div class="ft"></div> 
 </div>

-------------------------------------------------------------------------
and in my upload.php
-------------------------------------------------------------------------


if($_SERVER['REQUEST_METHOD']=='POST') {
  $status = apc_fetch('upload_'.$_POST['APC_UPLOAD_PROGRESS']);
  $status['msg'] = 'blah';
  echo json_encode($status);
  exit;
} else if(isset($_GET['progress_key'])) {
  $status = apc_fetch('upload_'.$_GET['progress_key']);
  echo json_encode($status);
}

-------------------------------------------------------------------------

I dont get the next page...

eZ debug

Timing: Jan 31 2025 03:44:43
Script start
Timing: Jan 31 2025 03:44:43
Module start 'content'
Timing: Jan 31 2025 03:44:43
Module end 'content'
Timing: Jan 31 2025 03:44:43
Script end

Main resources:

Total runtime0.2353 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.9297370.2969
Module start 'content' 0.00600.0114 958.22661,001.5313
Module end 'content' 0.01730.2179 1,959.75783,896.9375
Script end 0.2353  5,856.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00421.7879200.0002
Check MTime0.00130.5361200.0001
Mysql Total
Database connection0.00070.285510.0007
Mysqli_queries0.139259.16741410.0010
Looping result0.00130.53281390.0000
Template Total0.217592.410.2175
Template load0.00080.352310.0008
Template processing0.216692.054210.2166
Override
Cache load0.00060.237110.0006
Sytem overhead
Fetch class attribute can translate value0.00170.724510.0017
XML
Image XML parsing0.00030.138510.0003
General
dbfile0.00753.1676200.0004
String conversion0.00000.001230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0003 secs