<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Creating your own library in CodeIgniter</title>
	<link>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/</link>
	<description>FRee and Open Source Technologies</description>
	<pubDate>Wed, 07 Jan 2009 04:54:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
		<item>
		<title>By: admin</title>
		<link>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/#comment-71</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 03 Aug 2008 10:05:48 +0000</pubDate>
		<guid>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/#comment-71</guid>
		<description>&lt;style&gt;
code {font-size:1.2em;
     color: #008099}
&lt;/style&gt;

Hi Jonathan,

You have to create a wrapper library that will handle/call the class.upload.php file. Then you will use that wrapper inside your controller.

&lt;code&gt;
&lt;?php

// application/libraries/Wrapper.php

require 'class.upload.php';

class Wrapper  {


	function process($files_arr) {

		$handle = new upload($files_arr); //$_FILES['image_field']


		if ($handle-&gt;uploaded) {

		    $handle-&gt;file_new_name_body   = 'image_resized'; // the new name of the uploaded file
		    $handle-&gt;image_resize         = true;
		    $handle-&gt;image_x              = 150; // copied image width
		    $handle-&gt;image_ratio_y        = true;
		    $handle-&gt;process('/my/upload/dir/'); // upload destination, make sure it's writable by webserver

		    if ($handle-&gt;processed)  {
		    	echo 'image resized';
		        $handle-&gt;clean();

			} else {

		    	echo 'error : ' . $handle-&gt;error;

			}
		}

	}
	
}
&lt;/code&gt;


Then in your controller , you will use it like this:

&lt;code&gt;
&lt;?php
// application/controllers/testwrapper.php

class testwrapper extends Controller  {

	function __construct() 	{

		parent::__construct();
		$this-&gt;load-&gt;library('Wrapper');
	}
	
	
	function index() {

		$this-&gt;load-&gt;view("upload_form"); // view/template for file upload
	}
	
	function upload() {		

		$this-&gt;wrapper-&gt;process($_FILES['file']); // files array
	}	
}
&lt;/code&gt;

Now, on your view file :
// application/views/upload_form.php

&lt;code&gt;
&#60;form method=&#34;POST&#34; action=&#34;&#60;?=site_url('testwrapper/upload');?&#62;&#34; enctype=&#34;multipart/form-data&#34;&#62;

File : &#60;input type=&#34;file&#34; name=&#34;file&#34;&#62;
&#60;input type="submit" name="uploadfile" value="Upload File"&#62;
&#60;&#47;form&#62;
&lt;/code&gt;

Hope this helps and thanks for the comment.</description>
		<content:encoded><![CDATA[<style>
code {font-size:1.2em;
     color: #008099}
</style>
<p>Hi Jonathan,</p>
<p>You have to create a wrapper library that will handle/call the class.upload.php file. Then you will use that wrapper inside your controller.</p>
<p><code><br />
< ?php</p>
<p>// application/libraries/Wrapper.php</p>
<p>require 'class.upload.php';</p>
<p>class Wrapper  {</p>
<p>	function process($files_arr) {</p>
<p>		$handle = new upload($files_arr); //$_FILES['image_field']</p>
<p>		if ($handle->uploaded) {</p>
<p>		    $handle->file_new_name_body   = &#8216;image_resized&#8217;; // the new name of the uploaded file<br />
		    $handle->image_resize         = true;<br />
		    $handle->image_x              = 150; // copied image width<br />
		    $handle->image_ratio_y        = true;<br />
		    $handle->process(&#8217;/my/upload/dir/&#8217;); // upload destination, make sure it&#8217;s writable by webserver</p>
<p>		    if ($handle->processed)  {<br />
		    	echo &#8216;image resized&#8217;;<br />
		        $handle->clean();</p>
<p>			} else {</p>
<p>		    	echo &#8216;error : &#8216; . $handle->error;</p>
<p>			}<br />
		}</p>
<p>	}</p>
<p>}<br />
</code></p>
<p>Then in your controller , you will use it like this:</p>
<p><code><br />
< ?php<br />
// application/controllers/testwrapper.php</p>
<p>class testwrapper extends Controller  {</p>
<p>	function __construct() 	{</p>
<p>		parent::__construct();<br />
		$this->load->library(&#8217;Wrapper&#8217;);<br />
	}</p>
<p>	function index() {</p>
<p>		$this->load->view(&#8221;upload_form&#8221;); // view/template for file upload<br />
	}</p>
<p>	function upload() {		</p>
<p>		$this->wrapper->process($_FILES[&#8217;file&#8217;]); // files array<br />
	}<br />
}<br />
</code></p>
<p>Now, on your view file :<br />
// application/views/upload_form.php</p>
<p><code><br />
&lt;form method=&#34;POST&#34; action=&#34;&lt;?=site_url('testwrapper/upload');?&gt;&#34; enctype=&#34;multipart/form-data&#34;&gt;</p>
<p>File : &lt;input type=&#34;file&#34; name=&#34;file&#34;&gt;<br />
&lt;input type="submit" name="uploadfile" value="Upload File"&gt;<br />
&lt;&#47;form&gt;<br />
</code></p>
<p>Hope this helps and thanks for the comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jonatan</title>
		<link>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/#comment-69</link>
		<dc:creator>jonatan</dc:creator>
		<pubDate>Wed, 30 Jul 2008 13:12:09 +0000</pubDate>
		<guid>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/#comment-69</guid>
		<description>Hi!
Can you tell us how to use the class.upload (http://www.verot.net/php_class_upload.htm) in CI?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi!<br />
Can you tell us how to use the class.upload (http://www.verot.net/php_class_upload.htm) in CI?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
