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...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:14:33
Script start
Timing: Jan 31 2025 06:14:33
Module start 'layout'
Timing: Jan 31 2025 06:14:33
Module start 'content'
Timing: Jan 31 2025 06:14:34
Module end 'content'
Timing: Jan 31 2025 06:14:34
Script end

Main resources:

Total runtime0.6928 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0090 588.1406151.2109
Module start 'layout' 0.00900.0041 739.351636.6484
Module start 'content' 0.01310.6789 776.0000848.2344
Module end 'content' 0.69200.0008 1,624.234411.8516
Script end 0.6928  1,636.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4668160.0002
Check MTime0.00130.1876160.0001
Mysql Total
Database connection0.00180.260710.0018
Mysqli_queries0.644192.9650460.0140
Looping result0.00030.0483440.0000
Template Total0.654294.420.3271
Template load0.00200.291120.0010
Template processing0.652194.127120.3261
Template load and register function0.00110.164810.0011
states
state_id_array0.00100.147110.0010
state_identifier_array0.00070.096620.0003
Override
Cache load0.00160.2262240.0001
Sytem overhead
Fetch class attribute can translate value0.00050.065810.0005
Fetch class attribute name0.00150.220710.0015
XML
Image XML parsing0.00020.031510.0002
class_abstraction
Instantiating content class attribute0.00000.000410.0000
General
dbfile0.00320.4603100.0003
String conversion0.00000.001640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs