All pastes #965245 Raw Edit

XAJAX progress upload plugin

public php v1 · immutable
#965245 ·published 2008-03-31 21:10 UTC
rendered paste body
<?/*	File: upload.js		Title: progressupload plugin for xajax	*//*	@package progressupload plugin	@version $Id: 	@copyright Copyright (c) 2007 by Steffen Konerow 	@license http://www.xajaxproject.org/bsd_license.txt BSD License*//*	Class: xajax.ext.uploadProgress		This file demonstrates the uploadProgress plugin for xajax.*//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 	2007/01/19 00:45		-=[TODO]=-	PHP APC:		-		LIGHTY:		-	PHP FALLBACK:		- 	NGINX:		- 0 lines of code yet		CGI FALLBACK:		- 0 lines of code yet			GLOBAL:		- fix Rate NaN		- autocreate progressbar(?!?)		- elapsed / remaining time- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ini_set("display_errors",1);error_reporting(E_ALL ^E_NOTICE);$core = './xajax/xajax_core';require_once $core . '/xajax.inc.php';$xajax = new xajax();require_once './xajax/xajax_plugins/request/upload/upload.inc.php'; $xajax->configure("javascript URI","/upload/xajax/");$xajax->configure("UploadProgressType","PHP");$xajax->register(XAJAX_UPLOAD_FUNCTION,"uploader");$xajax->processRequest();function uploader($aFormValues) {	$objResponse = new xajaxResponse();	$objResponse->assign("results","innerHTML","woohooo! it works! this is a standard xajax response containing \n<pre>\$_FILES:\n ".print_r($_FILES,true)."\nAND formvalues:\n".print_r($aFormValues,true)."</pre>"	);	return $objResponse;}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><title>XAJAX UploadProgress Plugin</title><?php $xajax->printJavaScript();?><link rel="stylesheet" type="text/css" href="demo.css" /></head><body>	<h1>XAJAX ProgressUpload Plugin</h1>	<div id="docs">	<h2>vers 0.1</h2>		<p>			<h3>supported configurations:</h3>			<ul>				<li><a href="http://lighttpd.net/" target="_blank">lighttpd 1.5</a> / <a href="http://trac.lighttpd.net/trac/wiki/Docs%3AModUploadProgress" target="_blank">mod_progressupload</a> / php 5.2.x</li>				<li><a href="http://apache.org/" target="_blank">apache2</a> / php 5.2.x / <a href="http://de2.php.net/manual/en/ref.apc.php" target="_blank">APC</a> (no fast-cgi support)</li>				<li>Fallback - PHP 5.2.x  / any webserver (without progress)</li>			</ul>			<h3>support planned:</h3>			<ul>				<li>nginx / php 5.2.x</li>				<li>CGI fallback</li>			</ul>			<h3>supported browsers:</h3>			<ul>				<li>Firefox 2/3</li>				<li>IE 6/7 </li>				<li>Opera 9</li>				<li>Safari 3</li>			</ul>				</p>	</div>	<div id="example">		<h2>demo</h2>		<form enctype="multipart/form-data" id="upload_form" action="upload.php" onsubmit="return false;" method="post" >						<div class="formLabel">test field:</div>			<div class="formField"><input type="text" id="foo" name="foo" value="bar" /></div>			<br style="clear:both;" />			<div class="formLabel">Normal field 1:</div>			<div class="formField"><input type="file" id="upFile_standard" name="upFile_standard" value="" /></div>			<br style="clear:both;" />						<div class="formLabel">MultiFileField 1:</div>			<div class="formField"><div><input type="file" id="upFile" name="upFile" value=""  /></div></div>			<br style="clear:both;" />						<div class="formLabel">MultiFileField 2:</div>			<div class="formField"><div class="fileinputs"><input type="file" id="upFile2" name="upFile2" value=""  /></div></div>			<br style="clear:both;" />						<div class="formLabel">&nbsp;</div>			<div class="formField"><input type="button" onclick="xajax_uploader('upload_form');" value="upload file"/></div>			<br style="clear:both;" />		</form>		<br /><br />		<div id="xjxExtUpWin" >			<div>				<div class="xjxExtUpBox">					<div id="xjxExtUpBar"><div id="xjxExtUpBarTxt" style=""></div><div style="clear:both;"></div></div>				</div>				<div class="xjxExtUpBox">					<div class="xjxExtUpLabel">Rate</div><div id="xjxExtUpRate" class="xjxExtUpValue"></div><br style="clear:both;" />					<div class="xjxExtUpLabel">Bytes</div><div id="xjxExtUpBytes"  class="xjxExtUpValue"></div><br style="clear:both;" />				</div>			</div>		</div>	</div><br style="clear:both;" />	<div id="response">		<h2>response</h2>		<div id="results">		</div>	</div><div id="copyright">Copyright (c) 2007 by Steffen Konerow <br /></div><script type="text/javascript">	new xajax.ext.uploadProgress.transform(xajax.$('upFile'), 3 );	new xajax.ext.uploadProgress.transform(xajax.$('upFile2'), 5 );</script></body></html>