<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PHP Source Code</title>
	<atom:link href="http://phpsourcecode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpsourcecode.wordpress.com</link>
	<description>PHP Source Code Solutions</description>
	<lastBuildDate>Wed, 04 May 2011 15:20:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='phpsourcecode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>PHP Source Code</title>
		<link>http://phpsourcecode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://phpsourcecode.wordpress.com/osd.xml" title="PHP Source Code" />
	<atom:link rel='hub' href='http://phpsourcecode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Microsoft Web Application Installer</title>
		<link>http://phpsourcecode.wordpress.com/2008/10/17/microsoft-web-application-installer/</link>
		<comments>http://phpsourcecode.wordpress.com/2008/10/17/microsoft-web-application-installer/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 05:04:29 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Installer]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/?p=19</guid>
		<description><![CDATA[Overview The Web Application Installer Beta is designed to help get you up and running with the most widely used Web Applications freely available for your Windows Server. Web AI provides support for popular ASP.Net and PHP Web applications including Graffiti, DotNetNuke, WordPress, Drupal, OSCommerce and more. With just a few simple clicks, Web AI [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=19&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 style="padding-top:14px;">Overview</h3>
<p>The Web Application Installer Beta is designed to help get you up and running with the most widely used Web Applications freely available for your Windows Server. Web AI provides support for popular ASP.Net and PHP Web applications including Graffiti, DotNetNuke, WordPress, Drupal, OSCommerce and more. With just a few simple clicks, Web AI will check your machine for the necessary pre-requisites, download these applications from their source location in the community, walk you through basic configuration items and then install them on your computer.</p>
<p><a class="alignright" title="Microsoft Web Application Installer" href="http://phpmetablog.com/2008/10/17/microsoft-web-application-installer/" target="_blank"><br />
</a></p>
<h1><span style="color:#ff6600;"><a class="alignright" title="Microsoft Web Application Installer" href="http://phpmetablog.com/2008/10/17/microsoft-web-application-installer/" target="_blank">Full Story</a></span></h1>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=19&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2008/10/17/microsoft-web-application-installer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP Source Code &#8211; Meta Blog of Blogs</title>
		<link>http://phpsourcecode.wordpress.com/2008/09/09/php-source-code-meta-blog-of-blogs/</link>
		<comments>http://phpsourcecode.wordpress.com/2008/09/09/php-source-code-meta-blog-of-blogs/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 17:40:43 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[php help]]></category>
		<category><![CDATA[php job]]></category>
		<category><![CDATA[php news]]></category>
		<category><![CDATA[php scripts]]></category>
		<category><![CDATA[php source]]></category>
		<category><![CDATA[php technologies]]></category>
		<category><![CDATA[php tips]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/?p=12</guid>
		<description><![CDATA[phpmetablog.com is a blog spot where you can find php source php code source code php scripts php tips php news php technologies php help php job. PHP Source Code &#8211; Meta Blog of Blogs<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=12&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<blockquote><p>
phpmetablog.com is a blog spot where you can find php source php code source code php scripts php tips php news php technologies php help php job.
</p></blockquote>
<p><a class="alignright" title="PHP Source Code - Meta Blog of Blogs" href="http://www.phpmetablog.com" target="_blank">PHP Source Code &#8211; Meta Blog of Blogs</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpsourcecode.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpsourcecode.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=12&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2008/09/09/php-source-code-meta-blog-of-blogs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>
	</item>
		<item>
		<title>Updated files of class “ffmpeg” on PHP Classes</title>
		<link>http://phpsourcecode.wordpress.com/2008/03/05/updated-files-of-class-%e2%80%9cffmpeg%e2%80%9d-on-php-classes/</link>
		<comments>http://phpsourcecode.wordpress.com/2008/03/05/updated-files-of-class-%e2%80%9cffmpeg%e2%80%9d-on-php-classes/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 07:22:38 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[phpclasses.org]]></category>
		<category><![CDATA[php source code]]></category>
		<category><![CDATA[eff5.5gigs.com]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/2008/03/05/updated-files-of-class-%e2%80%9cffmpeg%e2%80%9d-on-php-classes/</guid>
		<description><![CDATA[Detailed description This class is a wrapper around the ffmpeg program to manipulate and convert video files. Currently it can perform several types of manipulation operations that include video format conversion, extract video frames into separate image files and assemble a video stream from a set of separate video images. Several parameters can also be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=11&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Detailed description</h1>
<blockquote><p>This class is a wrapper around the ffmpeg program to manipulate and convert video files.</p>
<p>Currently it can perform several types of manipulation operations that include video format conversion, extract video frames into separate image files and assemble a video stream from a set of separate video images.</p>
<p>Several parameters can also be configured like the output video file format (which can be Flash video or any other supported by ffmpeg), video and audio bit rate and sample rate, video dimensions and aspect ratio.</p></blockquote>
<h2>Added files</h2>
<p><b>1. Name:</b> 	ffmpeg.example8.php<br />
<b>Role: </b>	Example script<br />
<b>Description: </b>	An example script<br />
<b>2. Name: </b>	adapters/videoto.php<br />
<b></b><b>Role:</b> 	Auxiliary script<br />
Description: 	Simple video conversions class</p>
<h2>Changed files</h2>
<p><b>1. Name:</b> 	CHANGELOG<br />
<b>Role:</b> 	Documentation<br />
<b>Description:</b> 	Changlog<br />
<b>Changes:</b> 	Added version 0.1.0<br />
<b>2. Name:</b> 	ffmpeg.php<br />
<b>Role: </b>	Class source<br />
<b>Description:</b> 	Main Class File</p>
<h2>Changes:</h2>
<p>[0.1.0] [02.03.2008]<br />
- ADDED new constant ffmpeg::SIZE_SAS. Which stands for Same As Source,<br />
meaning ffmpeg will automatically convert the movie to a whatever format<br />
but preserve the size of the original movie.<br />
- CORRECTED error/comment spelling mistakes.<br />
- CHANGED ffmpeg::getFileInfo(); to use preg_match so it’s more reliable,<br />
it also contains more information on the file.<br />
- ADDED public function setVideoAspectRatio. Sets the video aspect ratio.<br />
Takes one of three constants as an argument. ffmpeg::RATIO_STANDARD,<br />
ffmpeg::RATIO_WIDE, ffmpeg::RATIO_CINEMATIC<br />
- ADDED public function setVideoBitRate. Sets the video bitrate.<br />
- ADDED public function setVideoFormat. Sets a video codec. It should not<br />
be confused with ffmpeg::setFormat. It provides slightly different<br />
advanced functionality, most simple usage can just use ffmpeg::setFormat.<br />
- ADDED public function setAudioFormat. Sets an audio codec.<br />
- ADDED public function setConstantQuality. Sets a constant encoding<br />
quality.<br />
- ADDED public function getFFmpegInfo. Gets the available data from ffmpeg<br />
and stores the output in ffmpeg::$ffmpeg_info (below).<br />
- ADDED ffmpeg::$ffmpeg_info static var to hold the output of<br />
ffmpeg::getFFmpegInfo();<br />
- ADDED public function getLastProcessTime and getProcessTime to retrieve<br />
the processing times of the ffmpeg calls.<br />
- ADDED adapter classes to provide simple functionality for ffmpeg newbies<br />
/ quick solutions. Each option set can be supplied in the second argument<br />
as part of an array.<br />
VideoTo::PSP(); &#8211; Converts video into the PSP mp4 video.<br />
VideoTo::iPod(); &#8211; Converts video into the iPod mp4 video.<br />
VideoTo::FLV(); &#8211; Converts video into the Flash video (flv).<br />
VideoTo::Gif(); &#8211; Converts video into the animated gif.<br />
(experimental as quality is poor)<br />
- CHANGED the way the processing works. The file is processed to the<br />
temp directory and is then checked for consistency before moving to<br />
the output directory.<br />
- CHANGED the return values of ffmpeg::execute(); It no longer returns<br />
just true or false. See class docs for more info.<br />
- CHANGED the third argument in ffmpeg::setOutput() from $overwrite to<br />
$overwrite_mode. Instead of a boolean value, it now takes one of three<br />
constants<br />
ffmegp::OVERWRITE_FAIL &#8211; means that if a conflict exists the<br />
process will result in and error.<br />
ffmegp::OVERWRITE_PRESERVE &#8211; means that if a conflict exists the<br />
process will preserve the existing<br />
file and report with<br />
ffmpeg::RESULT_OK_BUT_UNWRITABLE.<br />
ffmegp::OVERWRITE_EXISTING &#8211; means that if a conflict exists the<br />
process will overwrite any existing<br />
file with the new file.<br />
ffmegp::OVERWRITE_UNIQUE &#8211; means that every filename is prepended<br />
with a unique hash to preserve the<br />
existing filesystem.<br />
- MOVED error messages into a class variable for easier translation/changes.<br />
- CHANGED moveLog functionality to use rename instead of copy and unlink.</p>
<p>Download ffmpeg Class From  <a href="http://www.phpclasses.org/browse/download/zip/package/3747/name/ffmpeg-2008-03-04.zip">HERE<img src="http://i.ixnp.com/images/v3.19.1/t.gif" class="snap_preview_icon" style="border:0 none;font-style:normal;font-weight:normal;font-family:'trebuchet ms',arial,helvetica,sans-serif;float:none;position:static;left:auto;top:auto;line-height:normal;background-image:url('http://i.ixnp.com/images/v3.19.1/theme/green/palette.gif');background-color:transparent;width:14px;height:12px;background-position:-685px 0;background-repeat:no-repeat;text-decoration:none;visibility:visible;vertical-align:top;display:inline;margin:0 !important;padding:1px 0 0;" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpsourcecode.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpsourcecode.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=11&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2008/03/05/updated-files-of-class-%e2%80%9cffmpeg%e2%80%9d-on-php-classes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>

		<media:content url="http://i.ixnp.com/images/v3.19.1/t.gif" medium="image" />
	</item>
		<item>
		<title>Creating a Multi-File Upload Script in PHP</title>
		<link>http://phpsourcecode.wordpress.com/2007/12/12/creating-a-multi-file-upload-script-in-php/</link>
		<comments>http://phpsourcecode.wordpress.com/2007/12/12/creating-a-multi-file-upload-script-in-php/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 11:47:37 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[multi-file updload]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/2007/12/12/creating-a-multi-file-upload-script-in-php/</guid>
		<description><![CDATA[Frustrated with single-file upload scripts? Looking for an alternate route? Read as Jonathan shows us how easy it really is to setup a multi-file upload script using PHP.As a PHP programmer I had run into a problem where a client needed a form to upload more than one file at a time. So one night [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=10&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span class="txt">Frustrated with single-file upload scripts? Looking for an alternate route? Read as Jonathan shows us how easy it really is to setup a multi-file upload script using PHP.<span>As a PHP programmer I had run into a problem where a client needed a form to upload more than one file at a time. So one night I sat down and spent an hour figuring out the best and easiest way to do this. In this tutorial, the <b>for loop</b> is going to be your best friend.</span></span></p>
<p><span class="txt"><font face="Courier New" size="2">&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;# of Files to Upload&lt;/title&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243;&gt;<br />
&lt;/head&gt;</font></span></p>
<p><font face="Courier New" size="2">&lt;body&gt;<br />
&lt;form name=&#8221;form1&#8243; method=&#8221;post&#8221; action=&#8221;uploadForm2.php&#8221;&gt;<br />
&lt;p&gt;Enter the amount of boxes you will need below. Max = 9.&lt;/p&gt;<br />
&lt;p&gt;<br />
&lt;input name=&#8221;uploadNeed&#8221; type=&#8221;text&#8221; id=&#8221;uploadNeed&#8221; maxlength=&#8221;1&#8243;&gt;<br />
&lt;/p&gt;<br />
&lt;p&gt;<br />
&lt;input type=&#8221;submit&#8221; name=&#8221;Submit&#8221; value=&#8221;Submit&#8221;&gt;<br />
&lt;/p&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</font></p>
<p><span>As you can see this first page is very basic. In my form I set the uploadNeed maxlength to 1. This way the max upload boxes he or she can get is 9. You can increase or decrease this to satisfy your own project needs.</span></p>
<p><span class="txt"></span></p>
<h4><span><font face="Arial">uploadForm2.php</font></span></h4>
<p>Ok, this page will be doing one half of the work. We will be using the for loop to get this task done.</p>
<p><font face="Courier New" size="2">&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243;&gt;<br />
&lt;/head&gt;</font></p>
<p><font face="Courier New" size="2">&lt;body&gt;</font></p>
<p><font face="Courier New" size="2">&lt;form name=&#8221;form1&#8243; enctype=&#8221;multipart/form-data&#8221; method=&#8221;post&#8221; action=&#8221;processFiles.php&#8221;&gt;<br />
&lt;p&gt;<br />
&lt;?<br />
// start of dynamic form<br />
$uploadNeed = $_POST['uploadNeed'];<br />
for($x=0;$x&lt;$uploadNeed;$x++){<br />
?&gt;<br />
&lt;input name=&#8221;uploadFile&lt;? echo $x;?&gt;&#8221; type=&#8221;file&#8221; id=&#8221;uploadFile&lt;? echo $x;?&gt;&#8221;&gt;<br />
&lt;/p&gt;<br />
&lt;?<br />
// end of for loop<br />
}<br />
?&gt;<br />
&lt;p&gt;&lt;input name=&#8221;uploadNeed&#8221; type=&#8221;hidden&#8221; value=&#8221;&lt;? echo $uploadNeed;?&gt;&#8221;&gt;<br />
&lt;input type=&#8221;submit&#8221; name=&#8221;Submit&#8221; value=&#8221;Submit&#8221;&gt;<br />
&lt;/p&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</font></p>
<p>In this page, all I did was create a simple HTML form with the value of the attribute &#8220;type&#8221; set to &#8220;file&#8221;. Within the form I put a block of code to start the for loop. I set $x to 0 and I made it stop at the desired need by setting $x to be less than $uploadNeed – the value specified by the user. I also echo the $uploadNeed into a hidden input field to be carried over to the last page.</p>
<p>The key to making this all work however is the $x variable I am echoing right next to the uploadFile name. What this will do is append a number starting with 0 to the name. This in turn will make each upload field’s name unique.</p>
<p><span class="txt"></span></p>
<h4><span><font face="Arial">processFiles.php</font></span></h4>
<p>Here is the last page to complete our multiple upload tasks.</p>
<p><span><font face="Courier New" size="2">&lt;?<br />
$uploadNeed = $_POST['uploadNeed'];<br />
// start for loop<br />
for($x=0;$x&lt;$uploadNeed;$x++){<br />
$file_name = $_FILES['uploadFile'. $x]['name'];<br />
// strip file_name of slashes<br />
$file_name = stripslashes($file_name);<br />
$file_name = str_replace(&#8220;&#8216;&#8221;,&#8221;",$file_name);<br />
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);<br />
// check if successfully copied<br />
if($copy){<br />
echo &#8220;$file_name | uploaded sucessfully!&lt;br&gt;&#8221;;<br />
}else{<br />
echo &#8220;$file_name | could not be uploaded!&lt;br&gt;&#8221;;<br />
}<br />
} // end of loop<br />
?&gt;</font></span></p>
<p><span><span>The first thing we do in this page is grab the uploadNeed from uploadForm2.php. We setup our for loop in the same fashion as the last page. The difference here though is we get the $_FILES name within the for loop. I assign this to the local variable name $file_name. </span></span></p>
<p><span>Next, we do a little parsing by adding the stripslashes and str_replace functions. The reason we add the stripslashes is due to file that may have apostrophes in their name; otherwise this will generate a parse error and prevent that file from being uploaded. </span></p>
<p><span>Notice once again how I add the $x variable, which in turn is a number, to the name of the $_FILES. By doing this the script now knows which file it is uploading. </span></p>
<p><span>We will use the copy function now to actually begin the upload process. The last thing I added was a simple if statement to check that the copy was successful and I echo that message out to the screen.</span></p>
<p><span class="txt"><span>This little script I am sure will come in handy when you have multiple files that you want to upload all at once. Some other things you could add to this script are listed below.</span></span></p>
<ul>
<li><span>Insert file names into a mysql database.</span></li>
<li><span>Get the size of the file and store that in the database too.</span></li>
<li><span>Create a temp text file delimited by commas for the files that have trouble uploading and at the end of the script do a retry on those files.</span></li>
<li><span>Create a mass-delete of files.</span></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpsourcecode.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpsourcecode.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=10&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2007/12/12/creating-a-multi-file-upload-script-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>
	</item>
		<item>
		<title>Unzip file using PHP</title>
		<link>http://phpsourcecode.wordpress.com/2007/11/24/unzip-file-using-php/</link>
		<comments>http://phpsourcecode.wordpress.com/2007/11/24/unzip-file-using-php/#comments</comments>
		<pubDate>Sat, 24 Nov 2007 10:57:47 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[unzip]]></category>
		<category><![CDATA[unzip file]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/2007/11/24/unzip-file-using-php/</guid>
		<description><![CDATA[&#60;?php if (!function_exists(&#8216;file_put_contents&#8217;)) { // If not PHP5, creates a compatible function function file_put_contents($file, $data) { if ($tmp = fopen($file, &#8220;w&#8221;)) { fwrite($tmp, $data); fclose($tmp); return true; } echo &#8220;&#60;b&#62;file_put_contents:&#60;/b&#62; Cannot create file $file&#60;br&#62;&#8221;; return false; } } class dUnzip2 { function getVersion() { return &#8220;2.6&#8243;; } // Public var $fileName; var $compressedList; // You [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=7&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&lt;?php<br />
if (!function_exists(&#8216;file_put_contents&#8217;)) {<br />
// If not PHP5, creates a compatible function<br />
function file_put_contents($file, $data) {<br />
if ($tmp = fopen($file, &#8220;w&#8221;)) {<br />
fwrite($tmp, $data);<br />
fclose($tmp);<br />
return true;<br />
}<br />
echo &#8220;&lt;b&gt;file_put_contents:&lt;/b&gt; Cannot create file $file&lt;br&gt;&#8221;;<br />
return false;<br />
}<br />
}</p>
<p>class dUnzip2 {<br />
function getVersion() {<br />
return &#8220;2.6&#8243;;<br />
}<br />
// Public<br />
var $fileName;<br />
var $compressedList; // You will problably use only this one!<br />
var $centralDirList; // Central dir list&#8230; It&#8217;s a kind of &#8216;extra attributes&#8217; for a set of files<br />
var $endOfCentral; // End of central dir, contains ZIP Comments<br />
var $debug;</p>
<p>// Private<br />
var $fh;<br />
var $zipSignature = &#8220;\x50\x4b\x03\x04&#8243;; // local file header signature<br />
var $dirSignature = &#8220;\x50\x4b\x01\x02&#8243;; // central dir header signature<br />
var $dirSignatureE = &#8220;\x50\x4b\x05\x06&#8243;; // end of central dir signature</p>
<p>// Public<br />
function dUnzip2($fileName) {<br />
$this-&gt;fileName = $fileName;<br />
$this-&gt;compressedList = $this-&gt;centralDirList = $this-&gt;endOfCentral = Array ();<br />
}</p>
<p>function getList($stopOnFile = false) {<br />
if (sizeof($this-&gt;compressedList)) {<br />
$this-&gt;debugMsg(1, &#8220;Returning already loaded file list.&#8221;);<br />
return $this-&gt;compressedList;<br />
}</p>
<p>// Open file, and set file handler<br />
$fh = fopen($this-&gt;fileName, &#8220;r&#8221;);<br />
$this-&gt;fh = &amp; $fh;<br />
if (!$fh) {<br />
$this-&gt;debugMsg(2, &#8220;Failed to load file.&#8221;);<br />
return false;<br />
}</p>
<p>$this-&gt;debugMsg(1, &#8220;Loading list from &#8216;End of Central Dir&#8217; index list&#8230;&#8221;);<br />
if (!$this-&gt;_loadFileListByEOF($fh, $stopOnFile)) {<br />
$this-&gt;debugMsg(1, &#8220;Failed! Trying to load list looking for signatures&#8230;&#8221;);<br />
if (!$this-&gt;_loadFileListBySignatures($fh, $stopOnFile)) {<br />
$this-&gt;debugMsg(1, &#8220;Failed! Could not find any valid header.&#8221;);<br />
$this-&gt;debugMsg(2, &#8220;ZIP File is corrupted or empty&#8221;);<br />
return false;<br />
}<br />
}</p>
<p>if ($this-&gt;debug) {<br />
#&#8212;&#8212;- Debug compressedList<br />
$kkk = 0;<br />
echo &#8220;&lt;table border=&#8217;0&#8242; style=&#8217;font: 11px Verdana; border: 1px solid #000&#8242;&gt;&#8221;;<br />
foreach ($this-&gt;compressedList as $fileName =&gt; $item) {<br />
if (!$kkk &amp;&amp; $kkk = 1) {<br />
echo &#8220;&lt;tr style=&#8217;background: #ADA&#8217;&gt;&#8221;;<br />
foreach ($item as $fieldName =&gt; $value)<br />
echo &#8220;&lt;td&gt;$fieldName&lt;/td&gt;&#8221;;<br />
echo &#8216;&lt;/tr&gt;&#8217;;<br />
}<br />
echo &#8220;&lt;tr style=&#8217;background: #CFC&#8217;&gt;&#8221;;<br />
foreach ($item as $fieldName =&gt; $value) {<br />
if ($fieldName == &#8216;lastmod_datetime&#8217;)<br />
echo &#8220;&lt;td title=&#8217;$fieldName&#8217; nowrap=&#8217;nowrap&#8217;&gt;&#8221; . date(&#8220;d/m/Y H:i:s&#8221;, $value) . &#8220;&lt;/td&gt;&#8221;;<br />
else<br />
echo &#8220;&lt;td title=&#8217;$fieldName&#8217; nowrap=&#8217;nowrap&#8217;&gt;$value&lt;/td&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;/tr&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;/table&gt;&#8221;;</p>
<p>#&#8212;&#8212;- Debug centralDirList<br />
$kkk = 0;<br />
if (sizeof($this-&gt;centralDirList)) {<br />
echo &#8220;&lt;table border=&#8217;0&#8242; style=&#8217;font: 11px Verdana; border: 1px solid #000&#8242;&gt;&#8221;;<br />
foreach ($this-&gt;centralDirList as $fileName =&gt; $item) {<br />
if (!$kkk &amp;&amp; $kkk = 1) {<br />
echo &#8220;&lt;tr style=&#8217;background: #AAD&#8217;&gt;&#8221;;<br />
foreach ($item as $fieldName =&gt; $value)<br />
echo &#8220;&lt;td&gt;$fieldName&lt;/td&gt;&#8221;;<br />
echo &#8216;&lt;/tr&gt;&#8217;;<br />
}<br />
echo &#8220;&lt;tr style=&#8217;background: #CCF&#8217;&gt;&#8221;;<br />
foreach ($item as $fieldName =&gt; $value) {<br />
if ($fieldName == &#8216;lastmod_datetime&#8217;)<br />
echo &#8220;&lt;td title=&#8217;$fieldName&#8217; nowrap=&#8217;nowrap&#8217;&gt;&#8221; . date(&#8220;d/m/Y H:i:s&#8221;, $value) . &#8220;&lt;/td&gt;&#8221;;<br />
else<br />
echo &#8220;&lt;td title=&#8217;$fieldName&#8217; nowrap=&#8217;nowrap&#8217;&gt;$value&lt;/td&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;/tr&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;/table&gt;&#8221;;<br />
}</p>
<p>#&#8212;&#8212;- Debug endOfCentral<br />
$kkk = 0;<br />
if (sizeof($this-&gt;endOfCentral)) {<br />
echo &#8220;&lt;table border=&#8217;0&#8242; style=&#8217;font: 11px Verdana&#8217; style=&#8217;border: 1px solid #000&#8242;&gt;&#8221;;<br />
echo &#8220;&lt;tr style=&#8217;background: #DAA&#8217;&gt;&lt;td colspan=&#8217;2&#8242;&gt;dUnzip &#8211; End of file&lt;/td&gt;&lt;/tr&gt;&#8221;;<br />
foreach ($this-&gt;endOfCentral as $field =&gt; $value) {<br />
echo &#8220;&lt;tr&gt;&#8221;;<br />
echo &#8220;&lt;td style=&#8217;background: #FCC&#8217;&gt;$field&lt;/td&gt;&#8221;;<br />
echo &#8220;&lt;td style=&#8217;background: #FDD&#8217;&gt;$value&lt;/td&gt;&#8221;;<br />
echo &#8220;&lt;/tr&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;/table&gt;&#8221;;<br />
}<br />
}</p>
<p>return $this-&gt;compressedList;<br />
}<br />
function getExtraInfo($compressedFileName) {<br />
return isset ($this-&gt;centralDirList[$compressedFileName]) ? $this-&gt;centralDirList[$compressedFileName] : false;<br />
}<br />
function getZipInfo($detail = false) {<br />
return $detail ? $this-&gt;endOfCentral[$detail] : $this-&gt;endOfCentral;<br />
}</p>
<p>function unzip($compressedFileName, $targetFileName = false, $applyChmod = false) {<br />
if (!sizeof($this-&gt;compressedList)) {<br />
$this-&gt;debugMsg(1, &#8220;Trying to unzip before loading file list&#8230; Loading it!&#8221;);<br />
$this-&gt;getList(false, $compressedFileName);<br />
}</p>
<p>$fdetails = &amp; $this-&gt;compressedList[$compressedFileName];<br />
if (!isset ($this-&gt;compressedList[$compressedFileName])) {<br />
$this-&gt;debugMsg(2, &#8220;File &#8216;&lt;b&gt;$compressedFileName&lt;/b&gt;&#8217; is not compressed in the zip.&#8221;);<br />
return false;<br />
}<br />
if (substr($compressedFileName, -1) == &#8220;/&#8221;) {<br />
$this-&gt;debugMsg(2, &#8220;Trying to unzip a folder name &#8216;&lt;b&gt;$compressedFileName&lt;/b&gt;&#8217;.&#8221;);<br />
return false;<br />
}<br />
if (!$fdetails['uncompressed_size']) {<br />
$this-&gt;debugMsg(1, &#8220;File &#8216;&lt;b&gt;$compressedFileName&lt;/b&gt;&#8217; is empty.&#8221;);<br />
return $targetFileName ? file_put_contents($targetFileName, &#8220;&#8221;) : &#8220;&#8221;;<br />
}</p>
<p>fseek($this-&gt;fh, $fdetails['contents-startOffset']);<br />
$ret = $this-&gt;uncompress(fread($this-&gt;fh, $fdetails['compressed_size']), $fdetails['compression_method'], $fdetails['uncompressed_size'], $targetFileName);<br />
if ($applyChmod &amp;&amp; $targetFileName)<br />
chmod($targetFileName, 0777);</p>
<p>return $ret;<br />
}<br />
function unzipAll($targetDir = false, $baseDir = &#8220;&#8221;, $maintainStructure = true, $applyChmod = false) {<br />
if ($targetDir === false)<br />
$targetDir = dirname(__FILE__) . &#8220;/&#8221;;</p>
<p>$lista = $this-&gt;getList();<br />
if (sizeof($lista))<br />
foreach ($lista as $fileName =&gt; $trash) {<br />
$dirname = dirname($fileName);<br />
$outDN = &#8220;$targetDir/$dirname&#8221;;</p>
<p>if (substr($dirname, 0, strlen($baseDir)) != $baseDir)<br />
continue;</p>
<p>if (!is_dir($outDN) &amp;&amp; $maintainStructure) {<br />
$str = &#8220;&#8221;;<br />
$folders = explode(&#8220;/&#8221;, $dirname);<br />
foreach ($folders as $folder) {<br />
$str = $str ? &#8220;$str/$folder&#8221; : $folder;<br />
if (!is_dir(&#8220;$targetDir/$str&#8221;)) {<br />
$this-&gt;debugMsg(1, &#8220;Creating folder: $targetDir/$str&#8221;);<br />
mkdir(&#8220;$targetDir/$str&#8221;);<br />
if ($applyChmod)<br />
chmod(&#8220;$targetDir/$str&#8221;, $applyChmod);<br />
}<br />
}<br />
}<br />
if (substr($fileName, -1, 1) == &#8220;/&#8221;)<br />
continue;</p>
<p>$maintainStructure ? $this-&gt;unzip($fileName, &#8220;$targetDir/$fileName&#8221;, $applyChmod) : $this-&gt;unzip($fileName, &#8220;$targetDir/&#8221; . basename($fileName), $applyChmod);<br />
}<br />
}</p>
<p>function close() { // Free the file resource<br />
if ($this-&gt;fh)<br />
fclose($this-&gt;fh);<br />
}<br />
function __destroy() {<br />
$this-&gt;close();<br />
}</p>
<p>// Private (you should NOT call these methods):<br />
function uncompress($content, $mode, $uncompressedSize, $targetFileName = false) {<br />
switch ($mode) {<br />
case 0 :<br />
// Not compressed<br />
return $targetFileName ? file_put_contents($targetFileName, $content) : $content;<br />
case 1 :<br />
$this-&gt;debugMsg(2, &#8220;Shrunk mode is not supported&#8230; yet?&#8221;);<br />
return false;<br />
case 2 :<br />
case 3 :<br />
case 4 :<br />
case 5 :<br />
$this-&gt;debugMsg(2, &#8220;Compression factor &#8221; . ($mode -1) . &#8221; is not supported&#8230; yet?&#8221;);<br />
return false;<br />
case 6 :<br />
$this-&gt;debugMsg(2, &#8220;Implode is not supported&#8230; yet?&#8221;);<br />
return false;<br />
case 7 :<br />
$this-&gt;debugMsg(2, &#8220;Tokenizing compression algorithm is not supported&#8230; yet?&#8221;);<br />
return false;<br />
case 8 :<br />
// Deflate<br />
return $targetFileName ? file_put_contents($targetFileName, gzinflate($content, $uncompressedSize)) : gzinflate($content, $uncompressedSize);<br />
case 9 :<br />
$this-&gt;debugMsg(2, &#8220;Enhanced Deflating is not supported&#8230; yet?&#8221;);<br />
return false;<br />
case 10 :<br />
$this-&gt;debugMsg(2, &#8220;PKWARE Date Compression Library Impoloding is not supported&#8230; yet?&#8221;);<br />
return false;<br />
case 12 :<br />
// Bzip2<br />
return $targetFileName ? file_put_contents($targetFileName, bzdecompress($content)) : bzdecompress($content);<br />
case 18 :<br />
$this-&gt;debugMsg(2, &#8220;IBM TERSE is not supported&#8230; yet?&#8221;);<br />
return false;<br />
default :<br />
$this-&gt;debugMsg(2, &#8220;Unknown uncompress method: $mode&#8221;);<br />
return false;<br />
}<br />
}<br />
function debugMsg($level, $string) {<br />
if ($this-&gt;debug)<br />
if ($level == 1)<br />
echo &#8220;&lt;b style=&#8217;color: #777&#8242;&gt;dUnzip2:&lt;/b&gt; $string&lt;br&gt;&#8221;;<br />
if ($level == 2)<br />
echo &#8220;&lt;b style=&#8217;color: #F00&#8242;&gt;dUnzip2:&lt;/b&gt; $string&lt;br&gt;&#8221;;<br />
}</p>
<p>function _loadFileListByEOF(&amp; $fh, $stopOnFile = false) {<br />
// Check if there&#8217;s a valid Central Dir signature.<br />
// Let&#8217;s consider a file comment smaller than 1024 characters&#8230;<br />
// Actually, it length can be 65536.. But we&#8217;re not going to support it.</p>
<p>for ($x = 0; $x &lt; 1024; $x++) {<br />
fseek($fh, -22 &#8211; $x, SEEK_END);</p>
<p>$signature = fread($fh, 4);<br />
if ($signature == $this-&gt;dirSignatureE) {<br />
// If found EOF Central Dir<br />
$eodir['disk_number_this'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // number of this disk<br />
$eodir['disk_number'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // number of the disk with the start of the central directory<br />
$eodir['total_entries_this'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // total number of entries in the central dir on this disk<br />
$eodir['total_entries'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // total number of entries in<br />
$eodir['size_of_cd'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // size of the central directory<br />
$eodir['offset_start_cd'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // offset of start of central directory with respect to the starting disk number<br />
$zipFileCommentLenght = unpack(&#8220;v&#8221;, fread($fh, 2)); // zipfile comment length<br />
$eodir['zipfile_comment'] = $zipFileCommentLenght[1] ? fread($fh, $zipFileCommentLenght[1]) : &#8221;; // zipfile comment<br />
$this-&gt;endOfCentral = Array (<br />
&#8216;disk_number_this&#8217; =&gt; $eodir['disk_number_this'][1],<br />
&#8216;disk_number&#8217; =&gt; $eodir['disk_number'][1],<br />
&#8216;total_entries_this&#8217; =&gt; $eodir['total_entries_this'][1],<br />
&#8216;total_entries&#8217; =&gt; $eodir['total_entries'][1],<br />
&#8216;size_of_cd&#8217; =&gt; $eodir['size_of_cd'][1],<br />
&#8216;offset_start_cd&#8217; =&gt; $eodir['offset_start_cd'][1],<br />
&#8216;zipfile_comment&#8217; =&gt; $eodir['zipfile_comment'],</p>
<p>);</p>
<p>// Then, load file list<br />
fseek($fh, $this-&gt;endOfCentral['offset_start_cd']);<br />
$signature = fread($fh, 4);</p>
<p>while ($signature == $this-&gt;dirSignature) {<br />
$dir['version_madeby'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // version made by<br />
$dir['version_needed'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // version needed to extract<br />
$dir['general_bit_flag'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // general purpose bit flag<br />
$dir['compression_method'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // compression method<br />
$dir['lastmod_time'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // last mod file time<br />
$dir['lastmod_date'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // last mod file date<br />
$dir['crc-32'] = fread($fh, 4); // crc-32<br />
$dir['compressed_size'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // compressed size<br />
$dir['uncompressed_size'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // uncompressed size<br />
$fileNameLength = unpack(&#8220;v&#8221;, fread($fh, 2)); // filename length<br />
$extraFieldLength = unpack(&#8220;v&#8221;, fread($fh, 2)); // extra field length<br />
$fileCommentLength = unpack(&#8220;v&#8221;, fread($fh, 2)); // file comment length<br />
$dir['disk_number_start'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // disk number start<br />
$dir['internal_attributes'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // internal file attributes-byte1<br />
$dir['external_attributes1'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // external file attributes-byte2<br />
$dir['external_attributes2'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // external file attributes<br />
$dir['relative_offset'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // relative offset of local header<br />
$dir['file_name'] = fread($fh, $fileNameLength[1]); // filename<br />
$dir['extra_field'] = $extraFieldLength[1] ? fread($fh, $extraFieldLength[1]) : &#8221;; // extra field<br />
$dir['file_comment'] = $fileCommentLength[1] ? fread($fh, $fileCommentLength[1]) : &#8221;; // file comment</p>
<p>// Convert the date and time, from MS-DOS format to UNIX Timestamp<br />
$BINlastmod_date = str_pad(decbin($dir['lastmod_date'][1]), 16, &#8217;0&#8242;, STR_PAD_LEFT);<br />
$BINlastmod_time = str_pad(decbin($dir['lastmod_time'][1]), 16, &#8217;0&#8242;, STR_PAD_LEFT);<br />
$lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;<br />
$lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));<br />
$lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));<br />
$lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));<br />
$lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));<br />
$lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));</p>
<p>$this-&gt;centralDirList[$dir['file_name']] = Array (<br />
&#8216;version_madeby&#8217; =&gt; $dir['version_madeby'][1],<br />
&#8216;version_needed&#8217; =&gt; $dir['version_needed'][1],<br />
&#8216;general_bit_flag&#8217; =&gt; str_pad(decbin($dir['general_bit_flag'][1]<br />
), 8, &#8217;0&#8242;, STR_PAD_LEFT), &#8216;compression_method&#8217; =&gt; $dir['compression_method'][1], &#8216;lastmod_datetime&#8217; =&gt; mktime($lastmod_timeH, $lastmod_timeM, $lastmod_timeS, $lastmod_dateM, $lastmod_dateD, $lastmod_dateY), &#8216;crc-32&#8242; =&gt; str_pad(dechex(ord($dir['crc-32'][3])), 2, &#8217;0&#8242;, STR_PAD_LEFT) .<br />
str_pad(dechex(ord($dir['crc-32'][2])), 2, &#8217;0&#8242;, STR_PAD_LEFT) .<br />
str_pad(dechex(ord($dir['crc-32'][1])), 2, &#8217;0&#8242;, STR_PAD_LEFT) .<br />
str_pad(dechex(ord($dir['crc-32'][0])), 2, &#8217;0&#8242;, STR_PAD_LEFT), &#8216;compressed_size&#8217; =&gt; $dir['compressed_size'][1], &#8216;uncompressed_size&#8217; =&gt; $dir['uncompressed_size'][1], &#8216;disk_number_start&#8217; =&gt; $dir['disk_number_start'][1], &#8216;internal_attributes&#8217; =&gt; $dir['internal_attributes'][1], &#8216;external_attributes1&#8242; =&gt; $dir['external_attributes1'][1], &#8216;external_attributes2&#8242; =&gt; $dir['external_attributes2'][1], &#8216;relative_offset&#8217; =&gt; $dir['relative_offset'][1], &#8216;file_name&#8217; =&gt; $dir['file_name'], &#8216;extra_field&#8217; =&gt; $dir['extra_field'], &#8216;file_comment&#8217; =&gt; $dir['file_comment'],);<br />
$signature = fread($fh, 4);<br />
}</p>
<p>// If loaded centralDirs, then try to identify the offsetPosition of the compressed data.<br />
if ($this-&gt;centralDirList)<br />
foreach ($this-&gt;centralDirList as $filename =&gt; $details) {<br />
$i = $this-&gt;_getFileHeaderInformation($fh, $details['relative_offset']);<br />
$this-&gt;compressedList[$filename]['file_name'] = $filename;<br />
$this-&gt;compressedList[$filename]['compression_method'] = $details['compression_method'];<br />
$this-&gt;compressedList[$filename]['version_needed'] = $details['version_needed'];<br />
$this-&gt;compressedList[$filename]['lastmod_datetime'] = $details['lastmod_datetime'];<br />
$this-&gt;compressedList[$filename]['crc-32'] = $details['crc-32'];<br />
$this-&gt;compressedList[$filename]['compressed_size'] = $details['compressed_size'];<br />
$this-&gt;compressedList[$filename]['uncompressed_size'] = $details['uncompressed_size'];<br />
$this-&gt;compressedList[$filename]['lastmod_datetime'] = $details['lastmod_datetime'];<br />
$this-&gt;compressedList[$filename]['extra_field'] = $i['extra_field'];<br />
$this-&gt;compressedList[$filename]['contents-startOffset'] = $i['contents-startOffset'];<br />
if (strtolower($stopOnFile) == strtolower($filename))<br />
break;<br />
}<br />
return true;<br />
}<br />
}<br />
return false;<br />
}<br />
function _loadFileListBySignatures(&amp; $fh, $stopOnFile = false) {<br />
fseek($fh, 0);</p>
<p>$return = false;<br />
for (;;) {<br />
$details = $this-&gt;_getFileHeaderInformation($fh);<br />
if (!$details) {<br />
$this-&gt;debugMsg(1, &#8220;Invalid signature. Trying to verify if is old style Data Descriptor&#8230;&#8221;);<br />
fseek($fh, 12 &#8211; 4, SEEK_CUR); // 12: Data descriptor &#8211; 4: Signature (that will be read again)<br />
$details = $this-&gt;_getFileHeaderInformation($fh);<br />
}<br />
if (!$details) {<br />
$this-&gt;debugMsg(1, &#8220;Still invalid signature. Probably reached the end of the file.&#8221;);<br />
break;<br />
}<br />
$filename = $details['file_name'];<br />
$this-&gt;compressedList[$filename] = $details;<br />
$return = true;<br />
if (strtolower($stopOnFile) == strtolower($filename))<br />
break;<br />
}</p>
<p>return $return;<br />
}<br />
function _getFileHeaderInformation(&amp; $fh, $startOffset = false) {<br />
if ($startOffset !== false)<br />
fseek($fh, $startOffset);</p>
<p>$signature = fread($fh, 4);<br />
if ($signature == $this-&gt;zipSignature) {<br />
# $this-&gt;debugMsg(1, &#8220;Zip Signature!&#8221;);</p>
<p>// Get information about the zipped file<br />
$file['version_needed'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // version needed to extract<br />
$file['general_bit_flag'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // general purpose bit flag<br />
$file['compression_method'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // compression method<br />
$file['lastmod_time'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // last mod file time<br />
$file['lastmod_date'] = unpack(&#8220;v&#8221;, fread($fh, 2)); // last mod file date<br />
$file['crc-32'] = fread($fh, 4); // crc-32<br />
$file['compressed_size'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // compressed size<br />
$file['uncompressed_size'] = unpack(&#8220;V&#8221;, fread($fh, 4)); // uncompressed size<br />
$fileNameLength = unpack(&#8220;v&#8221;, fread($fh, 2)); // filename length<br />
$extraFieldLength = unpack(&#8220;v&#8221;, fread($fh, 2)); // extra field length<br />
$file['file_name'] = fread($fh, $fileNameLength[1]); // filename<br />
$file['extra_field'] = $extraFieldLength[1] ? fread($fh, $extraFieldLength[1]) : &#8221;; // extra field<br />
$file['contents-startOffset'] = ftell($fh);</p>
<p>// Bypass the whole compressed contents, and look for the next file<br />
fseek($fh, $file['compressed_size'][1], SEEK_CUR);</p>
<p>// Convert the date and time, from MS-DOS format to UNIX Timestamp<br />
$BINlastmod_date = str_pad(decbin($file['lastmod_date'][1]), 16, &#8217;0&#8242;, STR_PAD_LEFT);<br />
$BINlastmod_time = str_pad(decbin($file['lastmod_time'][1]), 16, &#8217;0&#8242;, STR_PAD_LEFT);<br />
$lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;<br />
$lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));<br />
$lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));<br />
$lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));<br />
$lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));<br />
$lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));</p>
<p>// Mount file table<br />
$i = Array (<br />
&#8216;file_name&#8217; =&gt; $file['file_name'],<br />
&#8216;compression_method&#8217; =&gt; $file['compression_method'][1],<br />
&#8216;version_needed&#8217; =&gt; $file['version_needed'][1],<br />
&#8216;lastmod_datetime&#8217; =&gt; mktime($lastmod_timeH,<br />
$lastmod_timeM,<br />
$lastmod_timeS,<br />
$lastmod_dateM,<br />
$lastmod_dateD,<br />
$lastmod_dateY<br />
), &#8216;crc-32&#8242; =&gt; str_pad(dechex(ord($file['crc-32'][3])), 2, &#8217;0&#8242;, STR_PAD_LEFT) .<br />
str_pad(dechex(ord($file['crc-32'][2])), 2, &#8217;0&#8242;, STR_PAD_LEFT) .<br />
str_pad(dechex(ord($file['crc-32'][1])), 2, &#8217;0&#8242;, STR_PAD_LEFT) .<br />
str_pad(dechex(ord($file['crc-32'][0])), 2, &#8217;0&#8242;, STR_PAD_LEFT), &#8216;compressed_size&#8217; =&gt; $file['compressed_size'][1], &#8216;uncompressed_size&#8217; =&gt; $file['uncompressed_size'][1], &#8216;extra_field&#8217; =&gt; $file['extra_field'], &#8216;general_bit_flag&#8217; =&gt; str_pad(decbin($file['general_bit_flag'][1]), 8, &#8217;0&#8242;, STR_PAD_LEFT), &#8216;contents-startOffset&#8217; =&gt; $file['contents-startOffset']);<br />
return $i;<br />
}<br />
return false;<br />
}<br />
}</p>
<p>$zip = new dUnzip2(&#8216;zipfile.zip&#8217;);<br />
$zip-&gt;debug = false; // you can enable if you want to show whats happning<br />
$zip-&gt;getList();<br />
$zip-&gt;unzipAll();</p>
<p>?&gt;</p>
<p>You can download this script from <a href="http://phpsourcecode.files.wordpress.com/2007/11/unzip.txt" title="Unzip file using PHP">here</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpsourcecode.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpsourcecode.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=7&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2007/11/24/unzip-file-using-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>
	</item>
		<item>
		<title>Move or Upload Folder Instead of File Using PHP FTP Functions</title>
		<link>http://phpsourcecode.wordpress.com/2007/11/22/move-or-upload-folder-instead-of-file-using-php-ftp-functions/</link>
		<comments>http://phpsourcecode.wordpress.com/2007/11/22/move-or-upload-folder-instead-of-file-using-php-ftp-functions/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 07:05:42 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/2007/11/22/move-or-upload-folder-instead-of-file-using-php-ftp-functions/</guid>
		<description><![CDATA[function moveFolder($_server, $_user_name, $_user_pass, $local_dir, $remote_dir) { // set up basic connection $_conn_id = ftp_connect($_server); // login with username and password $_login_result = ftp_login($_conn_id, $_user_name, $_user_pass); // check connection if ((!$_conn_id) &#124;&#124; (!$_login_result)) { $_error = &#8220;FTP connection has failed!&#8221;; $_error .= &#8220;Attempted to connect to $_server for user $_user_name&#8221;; $result = false; } else [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=6&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>function moveFolder($_server, $_user_name, $_user_pass, $local_dir, $remote_dir) {</p>
<p>// set up basic connection<br />
$_conn_id = ftp_connect($_server);</p>
<p>// login with username and password<br />
$_login_result = ftp_login($_conn_id, $_user_name, $_user_pass);</p>
<p>// check connection<br />
if ((!$_conn_id) || (!$_login_result)) {<br />
$_error = &#8220;FTP connection has failed!&#8221;;<br />
$_error .= &#8220;Attempted to connect to $_server for user $_user_name&#8221;;<br />
$result = false;<br />
} else {<br />
$_error = &#8220;Connected to $_server, for user $_user_name&#8221;;<br />
$result = true;<br />
}</p>
<p>$conn_id = $_conn_id;</p>
<p>@ ftp_mkdir($conn_id, $remote_dir);<br />
$handle = opendir($local_dir);<br />
while (($file = readdir($handle)) !== false) {<br />
if (($file != &#8216;.&#8217;) &amp;&amp; ($file != &#8216;..&#8217;)) {<br />
if (is_dir($local_dir . $file)) {<br />
//recursive call<br />
moveFolder($conn_id, $local_dir . $file . &#8216;/&#8217;, $remote_dir . $file . &#8216;/&#8217;);<br />
} else<br />
$f[] = $file;<br />
}<br />
}<br />
closedir($handle);<br />
if (count($f)) {<br />
sort($f);<br />
@ ftp_chdir($conn_id, $remote_dir);<br />
foreach ($f as $files) {<br />
$from = @ fopen(&#8220;$local_dir$files&#8221;, &#8216;r&#8217;);<br />
$moveFolder = ftp_fput($conn_id, $files, $from, FTP_BINARY);</p>
<p>// check upload status<br />
if (!$moveFolder) {<br />
$this-&gt;_error = &#8220;FTP upload has failed! From: &#8221; . $local_dir . &#8221; To: &#8221; . $remote_dir;<br />
$result = false;<br />
} else {<br />
$this-&gt;_error = &#8220;Uploaded $local_dir to $remote_dir as $this-&gt;_server&#8221;;<br />
$result = true;<br />
}<br />
}<br />
}<br />
return $result;<br />
}</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpsourcecode.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpsourcecode.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=6&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2007/11/22/move-or-upload-folder-instead-of-file-using-php-ftp-functions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>
	</item>
		<item>
		<title>Export Data From MySql to CSV (xls)</title>
		<link>http://phpsourcecode.wordpress.com/2007/11/09/export-data-from-mysql-to-csv-xls/</link>
		<comments>http://phpsourcecode.wordpress.com/2007/11/09/export-data-from-mysql-to-csv-xls/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 07:30:37 +0000</pubDate>
		<dc:creator>Haroon Sajjad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[csv header]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[table field names]]></category>

		<guid isPermaLink="false">http://phpsourcecode.wordpress.com/2007/11/09/export-data-from-mysql-to-csv-xls/</guid>
		<description><![CDATA[Here is a simple code example to export mysql database  data to csv (delimated)  data. &#60;?php //a small class for database connectivity class database { private $db_handle; private $user_name; private $password; private $data_base; private $host_name; private $sql; private $results; function __construct($host = &#8220;localhost&#8221;, $user, $passwd) { $this-&#62;db_handle = mysql_connect($host, $user, $passwd); } function dbSelect($db) { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=3&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a simple code example to export mysql database  data to csv (delimated)  data.</p>
<p>&lt;?php<br />
//a small class for database connectivity<br />
class database {<br />
private $db_handle;<br />
private $user_name;<br />
private $password;<br />
private $data_base;<br />
private $host_name;<br />
private $sql;<br />
private $results;</p>
<p>function __construct($host = &#8220;localhost&#8221;, $user, $passwd) {<br />
$this-&gt;db_handle = mysql_connect($host, $user, $passwd);<br />
}</p>
<p>function dbSelect($db) {<br />
$this-&gt;data_base = $db;<br />
if (!mysql_select_db($this-&gt;data_base, $this-&gt;db_handle)) {<br />
error_log(mysql_error(), 3, &#8220;/phplog.err&#8221;);<br />
die(&#8220;Error connecting to Database&#8221;);<br />
}<br />
}</p>
<p>function executeSql($sql_stmt) {<br />
$this-&gt;sql = $sql_stmt;<br />
$this-&gt;result = mysql_query($this-&gt;sql);<br />
}<br />
function returnResults() {<br />
return $this-&gt;result;<br />
}<br />
}</p>
<p>//database variables<br />
$host = &#8220;localhost&#8221;;<br />
$user = &#8220;root&#8221;;<br />
$passwd = &#8220;&#8221;;<br />
$db = &#8220;bg_db&#8221;;<br />
$sql = &#8220;SELECT * FROM table ORDER BY id&#8221;; // a query to fetch records from database</p>
<p>$dbObject = new database($host, $user, $passwd);<br />
$dbObject-&gt;dbSelect($db);<br />
$dbObject-&gt;executeSql($sql);</p>
<p>$res = $dbObject-&gt;returnResults(); // result reasource</p>
<p>$newFileName = &#8220;emp_names.csv&#8221;; //file name that you want to create<br />
$fpWrite = fopen($newFileName, &#8220;w&#8221;); // open file as writable<br />
$nameStr = &#8220;&#8221;;</p>
<p>$rows = mysql_fetch_assoc($res); // fetching associate records</p>
<p>$sStr = &#8220;&#8221;;</p>
<p>//first store the fields name as header of csv in $sStr<br />
foreach($rows as $key=&gt;$val) {<br />
$sStr .= $key.&#8221;,&#8221;;<br />
}</p>
<p>//then store all records<br />
do {<br />
$sStr .= &#8220;&#8211; &#8212;&#8211;\n&#8221;; //to seprate every record<br />
foreach($rows as $key=&gt;$row) {<br />
$sStr .= $row.&#8221;,&#8221;;<br />
}<br />
}while($rows = mysql_fetch_assoc($res));</p>
<p>$sStrExp = explode(&#8220;&#8211; &#8212;&#8211;&#8221;, $sStr);//separate every record<br />
foreach($sStrExp as $val) {<br />
$sStr2 .= rtrim($val, &#8220;,&#8221;);<br />
}</p>
<p>echo $sStr2;</p>
<p>fwrite($fpWrite, $sStr2); //now write to csv file<br />
fclose($fpWrite);//close file<br />
?&gt;</p>
<p>that all<br />
enjoy&#8230;.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpsourcecode.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpsourcecode.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpsourcecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpsourcecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phpsourcecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phpsourcecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpsourcecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpsourcecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpsourcecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpsourcecode.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpsourcecode.wordpress.com&amp;blog=2087150&amp;post=3&amp;subd=phpsourcecode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phpsourcecode.wordpress.com/2007/11/09/export-data-from-mysql-to-csv-xls/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc905982293e91615b07309c8a07c151?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">haroon</media:title>
		</media:content>
	</item>
	</channel>
</rss>
