<?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/"
	>

<channel>
	<title>Open source blog, linux, php, python, security &#187; upload</title>
	<atom:link href="http://www.alonon.net/tag/upload/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alonon.net</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 07:23:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>

   <image>
    <title>Open source blog, linux, php, python, security</title>
    <url>http://0.gravatar.com/avatar/5152c5736f5f8dd9570ffb2f9068e8ab.png?s=48</url>
    <link>http://www.alonon.net</link>
   </image>
		<item>
		<title>File upload class php</title>
		<link>http://www.alonon.net/file-upload-class-php/</link>
		<comments>http://www.alonon.net/file-upload-class-php/#comments</comments>
		<pubDate>Sun, 09 May 2010 16:13:03 +0000</pubDate>
		<dc:creator>ALonon</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://www.alonon.net/?p=291</guid>
		<description><![CDATA[PHP UPLOAD CLASS Properties You can choose type of file to be uploaded. For every type of file to be uploaded, you can choose biggest size of file which is allowed. Day, month and year choices are assigned as folder.( day/month/year or year/day depends on your wish.) Usage 1- Write type of file and the &#8230; <a href="http://www.alonon.net/file-upload-class-php/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2><a name="eng">PHP UPLOAD CLASS</a></h2>
<h3><strong>Properties</strong></h3>
<p>You can choose type of file to be uploaded.<br />
For every type of file to be uploaded, you can choose biggest size of  file which is allowed.<br />
Day, month and year choices are assigned as folder.( day/month/year or  year/day depends on your wish.)</p>
<h3><strong>Usage</strong></h3>
<p>1- Write type of file and the biggest size of file as byte format to  $file_types variable.For example, for jpep type “image/jpeg” =&gt;  30000. For more mime type, you can visit:</p>
<p>http://www.w3schools.com/media/media_mimeref.asp</p>
<p>2- Write the file to be uploaded to $path variable. For year  “%year%”    is used, for month  “ %month% ” for day %day% are also  used.As a example, your file name is af and for archiving the file  monthly,                 “af %month%” is used.</p>
<p>3- To rename your file, choice of $new_name must be true otherwise  choice must be changed as false.</p>
<p>4- $path_right is used for new file to be created.</p>
<p>5- Include “af_fileupload_class.php” file to the file to be used.</p>
<p>6- Create a new class, $a= new af_upload();</p>
<p>7- Send received file to upload function,</p>
<p>$a-&gt;upload ($_FILES ['uploadedfile']);</p>
<p><span style="color: #ff0000;">af_fileupload_class.php</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*
 * @ Author: Onur AKTAŞ (alonon@gmail.com)
 * @ Homepage: http://www.acikfikir.org
 * @ Release date: 02.05.2010
 * @ Version 1.0
 * @ Thanks Süleyman Çelik, Alper İpek, Emre Çamalan
 */
class af_upload {
 /* mime types and max size (as byte)
 * 1000 byte = 1 KB
 * for more  mime type visit http://www.w3schools.com/media/media_mimeref.asp
 */
 var $file_types = array (&quot;image/jpeg&quot; =&gt; 30000, &quot;application/pdf&quot; =&gt; 4000 );
 // %year% for year, %month% for month, %day% for day, or just write exact path.
 var $path ='alper/%year%/%month%/%day%';
 // false don't give a new name, true give a new name.
 var $new_name = FALSE;
 var $path_right = '0777';
 var $error = &quot;&quot;;
 var $is_error = FALSE;
 public function control_file($file) {
 if (!array_key_exists ( $file ['type'], $this-&gt;file_types )) {
 $this-&gt;error='this type is not allowed';
 $this-&gt;is_error = TRUE;
 }
 else {
 if ($file ['size'] &gt; $this-&gt;file_types [$file ['type']]) {
 $this-&gt;error=&quot;file is too big&quot;;
 $this-&gt;is_error = TRUE;
 }
 }
 }

 public function upload($file,$path=&quot;&quot;,$new_name=&quot;&quot;) {
 $this-&gt;control_file($file);
 if ($this-&gt;is_error) {
 echo $this-&gt;error;
 }
 else {
 $ext = substr(basename($file['name']), strrpos(basename($file['name']), '.') + 1);
 //giving name start
 if($this-&gt;new_name)
 $filename = time().&quot;.&quot;.$ext;
 else
 $filename = basename($file['name']);
 //giving name finish

 // Replace path with real value start
 $path_keys = array('%year%','%month%','%day%');
 $replace_keys = array(date(&quot;Y&quot;),date(&quot;m&quot;),date(&quot;d&quot;));
 for($i=0;$i&lt;=2;$i++) {
 $this-&gt;path =str_replace($path_keys[$i], $replace_keys[$i], $this-&gt;path);
 }
 $umask = umask(0);
 if(!is_dir($this-&gt;path)) {

 if(!@mkdir($this-&gt;path,0777,true)) {
 $this-&gt;error=&quot;can not create a folder&quot;;
 $this-&gt;is_error = TRUE;
 }

 }
 if(!@move_uploaded_file($file['tmp_name'], $this-&gt;path.'/'.$filename)) {
 $this-&gt;error=&quot;can not upload file&quot;;
 $this-&gt;is_error = TRUE;
 }
 umask($umask);
 }
 }
}
?&gt;
</pre>
<p><span style="color: #ff0000;">index.html</span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
&lt;title&gt; Af php upload sınıfı&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form enctype=&quot;multipart/form-data&quot; action=&quot;example.php&quot; method=&quot;POST&quot;&gt;
Dosya seçin: &lt;input name=&quot;uploadedfile&quot; type=&quot;file&quot; /&gt; &lt;br /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Upload File&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><span style="color: #ff0000;">example.php</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
include &quot;af_fileupload_class.php&quot;;
&lt;pre&gt;$a = new af_upload ();
$a-&gt;upload ($_FILES ['uploadedfile']);
?&gt;
</pre>
<p>To download, use this adress:  <a href="http://www.acikfikir.org/dosyalar/af_upload_class.tar.gz">www.acikfikir.org/dosyalar/af_upload_class.tar.gz</a> For advice and question, contact mail : alonon {@} gmail.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alonon.net/file-upload-class-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

