<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: PECL Uploadprogress example</title>
	<atom:link href="http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/</link>
	<description>Harper Reed: Software, PHP, MySQL, XMPP, Hacking, Baphomet</description>
	<pubDate>Sun, 12 Oct 2008 02:37:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7-hemorrhage</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Will Mason</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-64503</link>
		<dc:creator>Will Mason</dc:creator>
		<pubDate>Wed, 13 Feb 2008 20:14:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-64503</guid>
		<description>I dot this thing working with a little tweaking, and the damn thing is brilliant. Here is my implementation. I find it simple, but thats because it fits into my custom MVC. Please note I am using jQuery for client-side DOM manipulation, and xAjax for Async requests (upload progress).

MARKUP (upload.html):
	
		&#60;input name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="" type="hidden" /&#62;
		&#60;input name="UPLOAD_IDENTIFIER" id="UPLOAD_IDENTIFIER" value="" type="hidden" /&#62;
		
		
	
	
UPLOAD PROCESSOR (processUpload.php):
	
	
	
	
		
		
	
		window.parent.fileUpload.finish();
	
	


JS HELPER (fileUpload.js):
	$(function(){
		fileUpload.init();
	});
	var fileUpload = {
		timer: null,
		timeout: 800,
		iFrame: null,
		init: function (){
			$.xajaxLoad({bind: false});
		},
		start: function (el){
			$.xajaxLoad.show();
			this.checkProgress();
			this.iFrame = $('#' + el.form.target);
			el.form.submit();
		},
		checkProgress: function (){
			var fUp = this;
			if ($('#xajaxLoad').size() == 0)
				return false;
			if ($('#uploadProgress').size() == 0)
			{
				$('#xajaxLoad').append(
					''
						+ ''
						+ '0%'
	//					+ '0kb/s'
						+ '* Seconds Left'
						+ '&lt;a href="#" rel="nofollow"&gt;Cancel&lt;/a&gt;'
					+ ''
				);
	
				$('#UP_cancel').click(function(e){
					e.preventDefault();
					fUp.iFrame.attr('src', 'about:blank');
					clearTimeout(fUp.timer);
					$.xajaxLoad.hide();
				});
			}
			xDoUpdateBytesSent({
	//				avgSpeed: 'UP_avgSpeed',
					timeLeft: 'UP_timeLeft',
					percent: 'UP_percent',
					percentBar: 'UP_percentBar',
					id: $('#UPLOAD_IDENTIFIER').val()
			});
			this.timer = setTimeout('fileUpload.checkProgress()', this.timeout);
		},
		finish: function (){
			clearTimeout(this.timer);
			$.xajaxLoad.hide();
			alertSaved();
		}
	};

XAJAX PHP FUNCTION:
	public function xDoUpdateBytesSent()
	{
		$info = uploadprogress_get_info($this-&#62;getParam("id"));
		if ($info)
		{
			if (($asDiv = $this-&#62;getParam("avgSpeed")))
			{
				$tmp = wmFileSystem::bytesToHuman($info['speed_average']);
				$this-&#62;xajaxResponse-&#62;addAssign($asDiv, "innerHTML", $tmp."/S");
			}
			if (($tlDiv = $this-&#62;getParam("timeLeft")))
			{
				$this-&#62;xajaxResponse-&#62;addAssign($tlDiv, "innerHTML", $info['est_sec']." Seconds Left");
			}
			if ($this-&#62;getParam("percent") &#124;&#124; $this-&#62;getParam("percentBar"))
			{
				$pDiv = $this-&#62;getParam("percent");
				$pbDiv = $this-&#62;getParam("percentBar");
				$tmp = floor($info['bytes_uploaded'] / $info['bytes_total'] * 100);
				if ($pDiv)
					$this-&#62;xajaxResponse-&#62;addAssign($pDiv, "innerHTML", $tmp."%");
				if ($pbDiv)
					$this-&#62;xajaxResponse-&#62;addScript("$('#".$pbDiv."').css({width: '".$tmp."%'});");
			}
		}
		return $this-&#62;xajaxResponse;
	}</description>
		<content:encoded><![CDATA[<p>I dot this thing working with a little tweaking, and the damn thing is brilliant. Here is my implementation. I find it simple, but thats because it fits into my custom MVC. Please note I am using jQuery for client-side DOM manipulation, and xAjax for Async requests (upload progress).</p>
<p>MARKUP (upload.html):</p>
<p>		&lt;input name=&#8221;MAX_FILE_SIZE&#8221; id=&#8221;MAX_FILE_SIZE&#8221; value=&#8221;" type=&#8221;hidden&#8221; /&gt;<br />
		&lt;input name=&#8221;UPLOAD_IDENTIFIER&#8221; id=&#8221;UPLOAD_IDENTIFIER&#8221; value=&#8221;" type=&#8221;hidden&#8221; /&gt;</p>
<p>UPLOAD PROCESSOR (processUpload.php):</p>
<p>		window.parent.fileUpload.finish();</p>
<p>JS HELPER (fileUpload.js):<br />
	$(function(){<br />
		fileUpload.init();<br />
	});<br />
	var fileUpload = {<br />
		timer: null,<br />
		timeout: 800,<br />
		iFrame: null,<br />
		init: function (){<br />
			$.xajaxLoad({bind: false});<br />
		},<br />
		start: function (el){<br />
			$.xajaxLoad.show();<br />
			this.checkProgress();<br />
			this.iFrame = $(&#8217;#&#8217; + el.form.target);<br />
			el.form.submit();<br />
		},<br />
		checkProgress: function (){<br />
			var fUp = this;<br />
			if ($(&#8217;#xajaxLoad&#8217;).size() == 0)<br />
				return false;<br />
			if ($(&#8217;#uploadProgress&#8217;).size() == 0)<br />
			{<br />
				$(&#8217;#xajaxLoad&#8217;).append(<br />
					&#8221;<br />
						+ &#8221;<br />
						+ &#8216;0%&#8217;<br />
	//					+ &#8216;0kb/s&#8217;<br />
						+ &#8216;* Seconds Left&#8217;<br />
						+ &#8216;<a href="#" rel="nofollow">Cancel</a>&#8216;<br />
					+ &#8221;<br />
				);</p>
<p>				$(&#8217;#UP_cancel&#8217;).click(function(e){<br />
					e.preventDefault();<br />
					fUp.iFrame.attr(&#8217;src&#8217;, &#8216;about:blank&#8217;);<br />
					clearTimeout(fUp.timer);<br />
					$.xajaxLoad.hide();<br />
				});<br />
			}<br />
			xDoUpdateBytesSent({<br />
	//				avgSpeed: &#8216;UP_avgSpeed&#8217;,<br />
					timeLeft: &#8216;UP_timeLeft&#8217;,<br />
					percent: &#8216;UP_percent&#8217;,<br />
					percentBar: &#8216;UP_percentBar&#8217;,<br />
					id: $(&#8217;#UPLOAD_IDENTIFIER&#8217;).val()<br />
			});<br />
			this.timer = setTimeout(&#8217;fileUpload.checkProgress()&#8217;, this.timeout);<br />
		},<br />
		finish: function (){<br />
			clearTimeout(this.timer);<br />
			$.xajaxLoad.hide();<br />
			alertSaved();<br />
		}<br />
	};</p>
<p>XAJAX PHP FUNCTION:<br />
	public function xDoUpdateBytesSent()<br />
	{<br />
		$info = uploadprogress_get_info($this-&gt;getParam(&#8221;id&#8221;));<br />
		if ($info)<br />
		{<br />
			if (($asDiv = $this-&gt;getParam(&#8221;avgSpeed&#8221;)))<br />
			{<br />
				$tmp = wmFileSystem::bytesToHuman($info['speed_average']);<br />
				$this-&gt;xajaxResponse-&gt;addAssign($asDiv, &#8220;innerHTML&#8221;, $tmp.&#8221;/S&#8221;);<br />
			}<br />
			if (($tlDiv = $this-&gt;getParam(&#8221;timeLeft&#8221;)))<br />
			{<br />
				$this-&gt;xajaxResponse-&gt;addAssign($tlDiv, &#8220;innerHTML&#8221;, $info['est_sec'].&#8221; Seconds Left&#8221;);<br />
			}<br />
			if ($this-&gt;getParam(&#8221;percent&#8221;) || $this-&gt;getParam(&#8221;percentBar&#8221;))<br />
			{<br />
				$pDiv = $this-&gt;getParam(&#8221;percent&#8221;);<br />
				$pbDiv = $this-&gt;getParam(&#8221;percentBar&#8221;);<br />
				$tmp = floor($info['bytes_uploaded'] / $info['bytes_total'] * 100);<br />
				if ($pDiv)<br />
					$this-&gt;xajaxResponse-&gt;addAssign($pDiv, &#8220;innerHTML&#8221;, $tmp.&#8221;%&#8221;);<br />
				if ($pbDiv)<br />
					$this-&gt;xajaxResponse-&gt;addScript(&#8221;$(&#8217;#&#8221;.$pbDiv.&#8221;&#8216;).css({width: &#8216;&#8221;.$tmp.&#8221;%&#8217;});&#8221;);<br />
			}<br />
		}<br />
		return $this-&gt;xajaxResponse;<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-61652</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Tue, 29 Jan 2008 10:19:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-61652</guid>
		<description>Be sure you change the example in progress.php so that $uniq_id is actually $unique_id, or at least so the variables are the same.  After I changed that it worked fine.</description>
		<content:encoded><![CDATA[<p>Be sure you change the example in progress.php so that $uniq_id is actually $unique_id, or at least so the variables are the same.  After I changed that it worked fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Whisky</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-61007</link>
		<dc:creator>Whisky</dc:creator>
		<pubDate>Thu, 24 Jan 2008 16:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-61007</guid>
		<description>I've got the same problem Sid had in post No. 2. Does anybody have a solution?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve got the same problem Sid had in post No. 2. Does anybody have a solution?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: miccio</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-51790</link>
		<dc:creator>miccio</dc:creator>
		<pubDate>Tue, 04 Dec 2007 14:47:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-51790</guid>
		<description>links to examples are broken..</description>
		<content:encoded><![CDATA[<p>links to examples are broken..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-31015</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 14 Aug 2007 12:15:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-31015</guid>
		<description>Sid - any chance you could let us know what tweaking you did, as I'm having a similar issue. Cheers.</description>
		<content:encoded><![CDATA[<p>Sid - any chance you could let us know what tweaking you did, as I&#8217;m having a similar issue. Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sid</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-30550</link>
		<dc:creator>Sid</dc:creator>
		<pubDate>Tue, 07 Aug 2007 01:23:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-30550</guid>
		<description>Hey, I got it to work with a little bit tweaking. Cheers!</description>
		<content:encoded><![CDATA[<p>Hey, I got it to work with a little bit tweaking. Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sid</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-30548</link>
		<dc:creator>Sid</dc:creator>
		<pubDate>Tue, 07 Aug 2007 01:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-30548</guid>
		<description>Thanks for the example, I understand it quite a bit more now. However I still can't get it to run. I think I have installed the extension correctly but uploadprogress_get_info($unique_id) just doesn't seem to be returning anything. Is there a way to verify that the extension is installed and working? My php version 5.2.1 (Ubuntu 7.04, apache 2) so that should be ok. And when I viewed phpinfo, I could see the extension listed there. Any idea?</description>
		<content:encoded><![CDATA[<p>Thanks for the example, I understand it quite a bit more now. However I still can&#8217;t get it to run. I think I have installed the extension correctly but uploadprogress_get_info($unique_id) just doesn&#8217;t seem to be returning anything. Is there a way to verify that the extension is installed and working? My php version 5.2.1 (Ubuntu 7.04, apache 2) so that should be ok. And when I viewed phpinfo, I could see the extension listed there. Any idea?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fredrik Davidsson</title>
		<link>http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-29382</link>
		<dc:creator>Fredrik Davidsson</dc:creator>
		<pubDate>Wed, 25 Jul 2007 11:44:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.nata2.org/2007/04/16/pecl-uploadprogress-example/#comment-29382</guid>
		<description>Hi,

Thanks for the information!

While doing some tests I placed the UPLOAD_IDENTIFIER tag after the file tag and that doesn't work.
It might help others if point that out.

Have a nice day.

Regards Fredrik
Sweden</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for the information!</p>
<p>While doing some tests I placed the UPLOAD_IDENTIFIER tag after the file tag and that doesn&#8217;t work.<br />
It might help others if point that out.</p>
<p>Have a nice day.</p>
<p>Regards Fredrik<br />
Sweden</p>
]]></content:encoded>
	</item>
</channel>
</rss>
