<?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: Classes for file uploading in PHP</title>
	<atom:link href="http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/feed/" rel="self" type="application/rss+xml" />
	<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/</link>
	<description>Polluting the internet since 2004</description>
	<lastBuildDate>Fri, 26 Feb 2010 16:32:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tom</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-914</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-914</guid>
		<description>Mmmmm.</description>
		<content:encoded><![CDATA[<p>Mmmmm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryce</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-915</link>
		<dc:creator>Bryce</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-915</guid>
		<description>Hey,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This code in conjunction with stickmans script were just what I was looking for in my administrator upload system.  I do have one question that I was wondering if you could help me with.  I created a little mockup using yours and stickmans code, and have been having trouble with the number of files uploaded. Specifically, if for example the max number of files is set to 5 and I upload 5 files, the system works fine, however if I try to upload less then 5 files, it doesn&#039;t work at all.  I was just wondering if you might know why its doing this.  My code is included below:&lt;/p&gt;
&lt;p&gt;&lt;pre&gt;&lt;html&gt;

&lt;head&gt;
    &lt;!--&#160;Include&#160;the&#160;javascript&#160;--&gt;
    &lt;script&#160;src=&quot;multifile_compressed.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;!--&#160;This&#160;is&#160;the&#160;form&#160;--&gt;
&lt;form&#160;enctype=&quot;multipart/form-data&quot;&#160;action=&quot;uploadtest.php?action=upload&quot;&#160;method&#160;=&#160;&quot;post&quot;&gt;
    &lt;!--&#160;The&#160;file&#160;element&#160;--&#160;NOTE:&#160;it&#160;has&#160;an&#160;ID&#160;--&gt;
    &lt;input&#160;id=&quot;my_file_element&quot;&#160;type=&quot;file&quot;&#160;name=&quot;file_1&quot;&#160;&gt;
    &lt;input&#160;type=&quot;submit&quot;&gt;
&lt;/form&gt;
Files:
&lt;!--&#160;This&#160;is&#160;where&#160;the&#160;output&#160;will&#160;appear&#160;--&gt;
&lt;div&#160;id=&quot;files_list&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    &lt;!--&#160;Create&#160;an&#160;instance&#160;of&#160;the&#160;multiSelector&#160;class,&#160;pass&#160;it&#160;the&#160;output&#160;target&#160;and&#160;the&#160;max&#160;number&#160;of&#160;files&#160;--&gt;
    var&#160;multi_selector&#160;=&#160;new&#160;MultiSelector(&#160;document.getElementById(&#160;&#039;files_list&#039;&#160;),&#160;3&#160;);
    &lt;!--&#160;Pass&#160;in&#160;the&#160;file&#160;element&#160;--&gt;
    multi_selector.addElement(&#160;document.getElementById(&#160;&#039;my_file_element&#039;&#160;)&#160;);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;



&lt;?php
/**
*&#160;This&#160;represents&#160;just&#160;the&#160;file&#160;portion&#160;of&#160;the&#160;form&#160;processing
*/
require_once(&#039;Upload.class.php&#039;);
require_once(&#039;MimeTypes.class.php&#039;);

if(isset($_GET[&#039;action&#039;]))&#160;{
&#160;&#160;&#160;$action&#160;=&#160;$_GET[&#039;action&#039;];

&#160;&#160;&#160;if($action&#160;==&#160;&#039;upload&#039;)&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;upload();
&#160;&#160;&#160;}
}


function&#160;upload()
{
&#160;&#160;&#160;//&#160;set&#160;destination&#160;folder
&#160;&#160;&#160;$destination&#160;=&#160;&#039;upload/&#039;;

&#160;&#160;&#160;$m&#160;=&#160;new&#160;AP_File_MimeTypes();
&#160;&#160;&#160;$types&#160;=&#160;$m-&gt;getTypes(&#039;image&#039;);
&#160;&#160;&#160;unset($m);

&#160;&#160;&#160;//&#160;start&#160;new&#160;upload&#160;object
&#160;&#160;&#160;$ul&#160;=&#160;new&#160;AP_File_Upload($types);

&#160;&#160;&#160;echo&#160;&quot;hello&quot;;

&#160;&#160;&#160;//&#160;loop&#160;through&#160;uploaded&#160;files&#160;and&#160;save&#160;each&#160;one
&#160;&#160;&#160;foreach($_FILES&#160;as&#160;$file)
&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;if($ul-&gt;save_file($file,$destination)&#160;==&#160;false)
&#160;&#160;&#160;&#160;&#160;&#160;{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;you&#039;ll&#160;want&#160;to&#160;handle&#160;error&#160;in&#160;some&#160;way
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;more&#160;elegant&#160;than&#160;dying
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;die($ul-&gt;get_error());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;}

&#160;&#160;&#160;&#160;//&#160;continue&#160;processing&#160;files&#160;as&#160;needed
}

?&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the code, and help</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>This code in conjunction with stickmans script were just what I was looking for in my administrator upload system.  I do have one question that I was wondering if you could help me with.  I created a little mockup using yours and stickmans code, and have been having trouble with the number of files uploaded. Specifically, if for example the max number of files is set to 5 and I upload 5 files, the system works fine, however if I try to upload less then 5 files, it doesn&#8217;t work at all.  I was just wondering if you might know why its doing this.  My code is included below:</p>
<p>
<pre>&lt;html&gt;

&lt;head&gt;
    &lt;!--&nbsp;Include&nbsp;the&nbsp;javascript&nbsp;--&gt;
    &lt;script&nbsp;src=&quot;multifile_compressed.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;!--&nbsp;This&nbsp;is&nbsp;the&nbsp;form&nbsp;--&gt;
&lt;form&nbsp;enctype=&quot;multipart/form-data&quot;&nbsp;action=&quot;uploadtest.php?action=upload&quot;&nbsp;method&nbsp;=&nbsp;&quot;post&quot;&gt;
    &lt;!--&nbsp;The&nbsp;file&nbsp;element&nbsp;--&nbsp;NOTE:&nbsp;it&nbsp;has&nbsp;an&nbsp;ID&nbsp;--&gt;
    &lt;input&nbsp;id=&quot;my_file_element&quot;&nbsp;type=&quot;file&quot;&nbsp;name=&quot;file_1&quot;&nbsp;&gt;
    &lt;input&nbsp;type=&quot;submit&quot;&gt;
&lt;/form&gt;
Files:
&lt;!--&nbsp;This&nbsp;is&nbsp;where&nbsp;the&nbsp;output&nbsp;will&nbsp;appear&nbsp;--&gt;
&lt;div&nbsp;id=&quot;files_list&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    &lt;!--&nbsp;Create&nbsp;an&nbsp;instance&nbsp;of&nbsp;the&nbsp;multiSelector&nbsp;class,&nbsp;pass&nbsp;it&nbsp;the&nbsp;output&nbsp;target&nbsp;and&nbsp;the&nbsp;max&nbsp;number&nbsp;of&nbsp;files&nbsp;--&gt;
    var&nbsp;multi_selector&nbsp;=&nbsp;new&nbsp;MultiSelector(&nbsp;document.getElementById(&nbsp;'files_list'&nbsp;),&nbsp;3&nbsp;);
    &lt;!--&nbsp;Pass&nbsp;in&nbsp;the&nbsp;file&nbsp;element&nbsp;--&gt;
    multi_selector.addElement(&nbsp;document.getElementById(&nbsp;'my_file_element'&nbsp;)&nbsp;);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

&lt;?php
/**
*&nbsp;This&nbsp;represents&nbsp;just&nbsp;the&nbsp;file&nbsp;portion&nbsp;of&nbsp;the&nbsp;form&nbsp;processing
*/
require_once('Upload.class.php');
require_once('MimeTypes.class.php');

if(isset($_GET['action']))&nbsp;{
&nbsp;&nbsp;&nbsp;$action&nbsp;=&nbsp;$_GET['action'];

&nbsp;&nbsp;&nbsp;if($action&nbsp;==&nbsp;'upload')&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;upload();
&nbsp;&nbsp;&nbsp;}
}

function&nbsp;upload()
{
&nbsp;&nbsp;&nbsp;//&nbsp;set&nbsp;destination&nbsp;folder
&nbsp;&nbsp;&nbsp;$destination&nbsp;=&nbsp;'upload/';

&nbsp;&nbsp;&nbsp;$m&nbsp;=&nbsp;new&nbsp;AP_File_MimeTypes();
&nbsp;&nbsp;&nbsp;$types&nbsp;=&nbsp;$m-&gt;getTypes('image');
&nbsp;&nbsp;&nbsp;unset($m);

&nbsp;&nbsp;&nbsp;//&nbsp;start&nbsp;new&nbsp;upload&nbsp;object
&nbsp;&nbsp;&nbsp;$ul&nbsp;=&nbsp;new&nbsp;AP_File_Upload($types);

&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;hello&quot;;

&nbsp;&nbsp;&nbsp;//&nbsp;loop&nbsp;through&nbsp;uploaded&nbsp;files&nbsp;and&nbsp;save&nbsp;each&nbsp;one
&nbsp;&nbsp;&nbsp;foreach($_FILES&nbsp;as&nbsp;$file)
&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if($ul-&gt;save_file($file,$destination)&nbsp;==&nbsp;false)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;you'll&nbsp;want&nbsp;to&nbsp;handle&nbsp;error&nbsp;in&nbsp;some&nbsp;way
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;more&nbsp;elegant&nbsp;than&nbsp;dying
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die($ul-&gt;get_error());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;continue&nbsp;processing&nbsp;files&nbsp;as&nbsp;needed
}

?&gt;
</pre>
</p>
</p>
<p>Thanks for the code, and help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roni</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-916</link>
		<dc:creator>Roni</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-916</guid>
		<description>First of all, a huge thank you for both you and stickman for this code.  That is great of you both to provide your code for all of us.  Unfortunately, I&#039;m having the same problem as Bryce.  If I upload the number of files that my max is set to, I have no problems.  But if I upload any less than the max, none of the files upload.  Any thoughts?  Any help you can provide is much appreciated.</description>
		<content:encoded><![CDATA[<p>First of all, a huge thank you for both you and stickman for this code.  That is great of you both to provide your code for all of us.  Unfortunately, I&#8217;m having the same problem as Bryce.  If I upload the number of files that my max is set to, I have no problems.  But if I upload any less than the max, none of the files upload.  Any thoughts?  Any help you can provide is much appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn Parker</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-917</link>
		<dc:creator>Shawn Parker</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-917</guid>
		<description>I finally got a minute to look at this and the error has been fixed above. I had forgotten a little quirk in the results of the script where if the limit wasn&#039;t reached then there would be an empty item in the $_FILES array.&lt;/p&gt;
&lt;p&gt;Unfortunately, Roni &amp; Bryce, you guys didn&#039;t leave your email address so hopefully you check back to find this soon.</description>
		<content:encoded><![CDATA[<p>I finally got a minute to look at this and the error has been fixed above. I had forgotten a little quirk in the results of the script where if the limit wasn&#8217;t reached then there would be an empty item in the $_FILES array.</p>
<p>Unfortunately, Roni &#038; Bryce, you guys didn&#8217;t leave your email address so hopefully you check back to find this soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: André</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-918</link>
		<dc:creator>André</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-918</guid>
		<description>Ijust tryed these scripts and classes ant i have the same error as decribed above. My max is three files and i select only one or two, i get the message &quot;No file uploaded. Please select a file to upload&quot;.&lt;/p&gt;
&lt;p&gt;I did not find where the test was done.&lt;/p&gt;
&lt;p&gt;Thanks for the code, thanks for help ?</description>
		<content:encoded><![CDATA[<p>Ijust tryed these scripts and classes ant i have the same error as decribed above. My max is three files and i select only one or two, i get the message &quot;No file uploaded. Please select a file to upload&quot;.</p>
<p>I did not find where the test was done.</p>
<p>Thanks for the code, thanks for help ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn Parker</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-919</link>
		<dc:creator>Shawn Parker</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-919</guid>
		<description>Just confirm, you tried it with the revised code from the post and not with the code from Bryce?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Bryce&#039;s code will work by changing one line. Change line 61 from:&lt;/p&gt;
&lt;p&gt;&lt;pre&gt;if($ul-&gt;save_file($file,$destination)&#160;==&#160;false)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;&lt;pre&gt;if(!empty($file[&#039;name&#039;])&#160;&amp;&amp;&#160;$ul-&gt;save_file($file,$destination)&#160;==&#160;false)&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Just confirm, you tried it with the revised code from the post and not with the code from Bryce?</p>
<p>Bryce&#8217;s code will work by changing one line. Change line 61 from:</p>
<p>
<pre>if($ul-&gt;save_file($file,$destination)&nbsp;==&nbsp;false)</pre>
</p>
<p>to</p>
<p>
<pre>if(!empty($file['name'])&nbsp;&amp;&amp;&nbsp;$ul-&gt;save_file($file,$destination)&nbsp;==&nbsp;false)</pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mobilfunk</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-920</link>
		<dc:creator>mobilfunk</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-920</guid>
		<description>Wow, this script in connection with a multiple file-upload-script is very useful. thanks for that!</description>
		<content:encoded><![CDATA[<p>Wow, this script in connection with a multiple file-upload-script is very useful. thanks for that!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: boggins</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-921</link>
		<dc:creator>boggins</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-921</guid>
		<description>coluld you please provide a php4 solution. I tried removing the public/private stuff, managed to get it to not produce any errors but it does not actually upload any files :-( Worked fine on php5, but my client has php4. I can&#039;t get the original script you posted on the stickman forum to work on 4 either.</description>
		<content:encoded><![CDATA[<p>coluld you please provide a php4 solution. I tried removing the public/private stuff, managed to get it to not produce any errors but it does not actually upload any files <img src='http://top-frog.com/wp/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  Worked fine on php5, but my client has php4. I can&#8217;t get the original script you posted on the stickman forum to work on 4 either.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn Parker</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-922</link>
		<dc:creator>Shawn Parker</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-922</guid>
		<description>Boggins, &lt;/p&gt;
&lt;p&gt;Sorry, but its not likely. I haven&#039;t worked on php4 in quite a while and I&#039;m pretty bogged down (to use the obvious pun). &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&#039;ll see if I can make time for it though.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As for the original script, not sure why it wouldn&#039;t work, that&#039;s code directly from a page I have in production now.</description>
		<content:encoded><![CDATA[<p>Boggins, </p>
<p>Sorry, but its not likely. I haven&#8217;t worked on php4 in quite a while and I&#8217;m pretty bogged down (to use the obvious pun). </p>
</p>
<p>I&#8217;ll see if I can make time for it though.</p>
</p>
<p>As for the original script, not sure why it wouldn&#8217;t work, that&#8217;s code directly from a page I have in production now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: boggins</title>
		<link>http://top-frog.com/2006/12/22/classes_for_file_uploading_in_php/comment-page-1/#comment-923</link>
		<dc:creator>boggins</dc:creator>
		<pubDate>Wed, 31 Dec 1969 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://top-frog.com/?p=205#comment-923</guid>
		<description>Shawn, thanks for the reply. Now sorted, nothing wrong with your script ;-)</description>
		<content:encoded><![CDATA[<p>Shawn, thanks for the reply. Now sorted, nothing wrong with your script <img src='http://top-frog.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>