cvs: pear /HTML_Progress2/examples/ajax/upload apc5_upload3.php

[email protected] ("Laurent Laville")
Newsgroups php.pear.cvs
Message-ID <cvsfarell1208625514@cvsserver>
farell		Sat Apr 19 17:18:34 2008 UTC

  Added files:                 
    /pear/HTML_Progress2/examples/ajax/upload	apc5_upload3.php 
  Log:
  initial commit of new example for request #12532 : Add addional info to apc5 "info"
  

http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/upload/apc5_upload3.php?view=markup&rev=1.1
Index: pear/HTML_Progress2/examples/ajax/upload/apc5_upload3.php
+++ pear/HTML_Progress2/examples/ajax/upload/apc5_upload3.php
<?php
/**
 * Custom example of AJAX file upload with HTML_Progress2, PHP 5.2+ and APC
 *
 * @version    $Id: apc5_upload3.php,v 1.1 2008/04/19 17:18:33 farell Exp $
 * @author     Laurent Laville <[email protected]>
 * @package    HTML_Progress2
 * @subpackage Examples
 * @access     public
 * @example    examples/ajax/upload/apc5_upload3.php
 *             AP5 basic upload source code
 * @link       http://www.laurent-laville.org/img/progress/screenshot/apc5_upload3.png
 *             screenshot (Image PNG, 429x137 pixels) 3,04 Kb
 */

require_once 'PEAR.php';
require_once 'HTML/Progress2.php';

PEAR::setErrorHandling(PEAR_ERROR_DIE);

// build a progress bar without default percentage label
$pb = new HTML_Progress2(null, HTML_PROGRESS2_BAR_HORIZONTAL, 0, 100);
$pb->setIdent('PB1');

// will replace the default uplStatus label with formatted option (see auto_server.php)
$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'sizeStatus');
// will show the current filename during upload
$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'fileName');

$pb->setCellCount(20);

$pb->setLabelAttributes('pct1', array(
    'width' => 400,
    'height' => 20,
    'valign' => 'center',
    'align' => 'center',
    'color' => 'navy'
));
$pb->setBorderPainted(true);
$pb->setCellAttributes(array(
    'active-color' => 'lightgrey',
    'inactive-color' => 'white',
    'width' => 20,
    'spacing' => 0
));
$pb->setBorderAttributes(array(
    'width' => 1,
    'style' => 'solid',
    'color' => 'black'
));
$pb->setLabelAttributes('fileName', 'valign=bottom align=left');

$pb->registerAJAX('auto_server.php', array('Request1APC5Status'));

// upload progress identifier : must be unique to avoid collision
$progress_key = md5(uniqid(rand(), true));
?>
<html>
<head>
<title>APC PHP5 AJAX Upload Progress Meter custom example </title>
<script type="text/javascript" src="HTML_Progress2.js"></script>
<?php echo $pb->setupAJAX(); ?>
<script type="text/javascript">
//<![CDATA[
HTML_Progress2.serverClassName  = 'Request1APC5Status';
HTML_Progress2.serverMethodName = 'getStatus';
HTML_Progress2.onComplete       = 'doNothing';

function beginUpload()
{
    HTML_Progress2.requestArgs = 'uploadID=<?php echo $progress_key; ?>';
    HTML_Progress2.start('<?php echo $pb->getIdent(); ?>', 1000);

}
function doNothing()
{
}
//]]>
</script>
<style type="text/css">
<!--
<?php echo $pb->getStyle(); ?>

body {background-color: #EEEEEE; }
 -->
</style>
</head>
<body>

<form enctype="multipart/form-data" target="tfrm" action="http_upload.php" method="post" onsubmit="beginUpload();">
  <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $progress_key; ?>">
  <input type="file" id="userfile"  name="userfile">
  <input type="submit" value="Upload!">
</form>
<iframe id="tfrm" name="tfrm" style="width:1px;height:1px;border:0"></iframe>

<?php $pb->display(); ?>

</body>
</html>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.