<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6770910695892884019</id><updated>2011-11-25T18:23:41.326+05:30</updated><category term='PEAR'/><category term='PHP'/><category term='Mobile'/><category term='JQuery'/><category term='System'/><category term='Anaglyph'/><category term='Internet'/><category term='SEO'/><category term='Multimedia'/><category term='Graphics'/><category term='3D'/><category term='How'/><category term='Technology'/><category term='CSS'/><category term='Javascript'/><category term='Database'/><category term='Fonts'/><category term='HTML'/><category term='AJAX'/><category term='GD'/><category term='XAMPP'/><category term='Hosts'/><category term='Web'/><category term='ASP.NET'/><title type='text'>Lasa Talkz...!</title><subtitle type='html'>Everything what I would like to talk...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-5411195120112792707</id><published>2011-05-18T17:12:00.000+05:30</published><updated>2011-05-18T17:12:30.499+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>Dynamically add HTML fields to a web form using Javascript/JQuery</title><content type='html'>&lt;p&gt;Imagine a situation where you need to create a web form which allows users to upload images to a web gallery… In this case you need to allow them to upload multiple images simultaneously. As long as you don’t know how many images the user going to upload, the best way to implement it is create a form with one file field and put a button to dynamically append more file fields to the form.&lt;/p&gt;&lt;p&gt;If you are familiar with Javascript/JQuery, it will be an easy task. You can create it as follows. (Please note that I am using the JQuery library, as it simplifies the code rather than using pure Javascript.)&lt;/p&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;// this function will be automatically called when the page is ready to display&lt;br /&gt;$(document).ready(function() {&lt;br /&gt; // bind the button's click event with the function&lt;br /&gt; $('#add_button').bind('click', function() {&lt;br /&gt;  // get the html content of the place holder and append new file field into it&lt;br /&gt;  var newContent = $('#place_holder').html() + '&amp;lt;input type="file" name="image[]" value="" /&amp;gt;&amp;lt;br /&amp;gt;';&lt;br /&gt;  // set the new html content to the place holder&lt;br /&gt;  $('#place_holder').html(newContent);&lt;br /&gt; });&lt;br /&gt;});&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;form method="post" action=""&amp;gt;&lt;br /&gt; &amp;lt;input type="button" value="Add new file" id="add_button" /&amp;gt;&amp;lt;hr /&amp;gt;&lt;br /&gt;    &amp;lt;span id="place_holder"&amp;gt;&lt;br /&gt;     &amp;lt;input type="file" name="image[]" value="" /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;    &amp;lt;/span&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;As you can see, it is a really easy task. But when you put this code into action, you’ll notice there is a small problem with it. The problem is, whenever you add new file field, the files you already selected will lose. To solve it you have to do a little tweak to this code. The tweaked code is as follows.&lt;/p&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;var counter = 1;&lt;br /&gt;// this function will be automatically called when the page is ready to display&lt;br /&gt;$(document).ready(function() {&lt;br /&gt; // bind the button's click event with the function&lt;br /&gt; $('#add_button').bind('click', function() {&lt;br /&gt;  // generate html for new file field and create new place holder too (with new id)&lt;br /&gt;  var newContent = '&amp;lt;input type="file" name="image[]" value="" /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;span id="next_position_' + (counter + 1) + '"&amp;gt;&amp;lt;/span&amp;gt;';&lt;br /&gt;  // set the new html content to the place holder&lt;br /&gt;  $('#next_position_' + counter).html(newContent);&lt;br /&gt;  // increment the counter by one&lt;br /&gt;  counter++;&lt;br /&gt; });&lt;br /&gt;});&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;form method="post" action=""&amp;gt;&lt;br /&gt; &amp;lt;input type="button" value="Add new file" id="add_button" /&amp;gt;&amp;lt;hr /&amp;gt;&lt;br /&gt;    &amp;lt;span id="file_set"&amp;gt;&lt;br /&gt;     &amp;lt;input type="file" name="image[]" value="" /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;        &amp;lt;span id="next_position_1"&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;    &amp;lt;/span&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;In this method, we first create a place holder for the field. When the user clicks the button, we add the new file field as well as a new place holder with new ID into the current place holder. As long as this code does not re-write HTML for existing fields, contents of the fields will not affect anymore.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-5411195120112792707?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/5411195120112792707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2011/05/dynamically-add-html-fields-to-web-form.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/5411195120112792707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/5411195120112792707'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2011/05/dynamically-add-html-fields-to-web-form.html' title='Dynamically add HTML fields to a web form using Javascript/JQuery'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-8785955474855334935</id><published>2011-05-02T09:27:00.004+05:30</published><updated>2011-05-02T09:35:08.581+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Browse internet from the Windows mobile device emulator?</title><content type='html'>&lt;p&gt;Windows mobile device emulator, cannot access internet even though your computer is connected to 24x7 internet connection. That is because, the device emulator works exactly same as a virtual machine. Simply, emulator runs an operating system (guest OS) on the PCs operating system (host OS), the same concept behind the virtualization. The emulator works as the hypervisor, and manages resources between the host and guest Oss, but note that it does not establish any connection between the two operating systems.&lt;/p&gt;&lt;p&gt;Since the emulator is another machine, you cannot access the internet through the emulator directly, without establishing a bridge between them (the guest and the host).&lt;/p&gt;&lt;p&gt;Here are the steps you need to follow. (Please note that I’m considering only Microsoft Windows XP operating system, and this will not work same as on Windows Vista/7.)&lt;/p&gt;&lt;p&gt;1.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;First you have to download and install Microsoft ActiveSync from the Microsoft download center. It is a small setup of 7.5MB.&lt;/p&gt;&lt;p&gt;2.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;If you are using Visual studio, go to “Tools” menu and select “Device Emulator Manager”. It’ll open the “Device Emulator Manager” window. If you need to start the emulator as standalone application, go to “Run” and type,&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;C:\Program Files\Microsoft Device Emulator\1.0\dvcemumanager.exe&lt;/div&gt;&lt;/p&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-zWuTOOMDxIg/Tb4pbIgLgBI/AAAAAAAAAOQ/T8p5RBBNjlg/s1600/1.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-zWuTOOMDxIg/Tb4pbIgLgBI/AAAAAAAAAOQ/T8p5RBBNjlg/s1600/1.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Device emulator manager in the Visual studio 2008 menubar&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-7dojyz6GNVM/Tb4pmcVktSI/AAAAAAAAAOU/F0ztp_J7r3I/s1600/2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="238" src="http://1.bp.blogspot.com/-7dojyz6GNVM/Tb4pmcVktSI/AAAAAAAAAOU/F0ztp_J7r3I/s320/2.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Device emulator manager window&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;3.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Once the window opened, right click on the preferred emulator and select “Connect”. In a while, the device emulator will open, and the emulator entry in the “Device Emulator Manager” will show a green arrow.&lt;/p&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-UfLg9aYcdBQ/Tb4p9Bt2NSI/AAAAAAAAAOY/61pdT2vLkaA/s1600/3.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="87" src="http://1.bp.blogspot.com/-UfLg9aYcdBQ/Tb4p9Bt2NSI/AAAAAAAAAOY/61pdT2vLkaA/s320/3.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Green arrow in the the Device emulator manager&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-pFRT9H22kA8/Tb4p_MYDlBI/AAAAAAAAAOc/9erVnLnQbRg/s1600/4.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="130" src="http://4.bp.blogspot.com/-pFRT9H22kA8/Tb4p_MYDlBI/AAAAAAAAAOc/9erVnLnQbRg/s320/4.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Note the "Connect" and "Craddle" menu items in the context menu&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;4.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Again right click on the same emulator entry, and select “Cradle”. Once you click it, the ActiveSync window will appear on the host OS, and will display as “Connected”.&lt;/p&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-S_GjyN4q8z0/Tb4qCFnVbrI/AAAAAAAAAOg/8Xr1F_qTB6I/s1600/5.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-S_GjyN4q8z0/Tb4qCFnVbrI/AAAAAAAAAOg/8Xr1F_qTB6I/s1600/5.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Connected status in the ActiveSync window&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;5.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Now everything is completed. Open Internet explorer in the mobile device and put a URL. You’ll navigate to the page in the internet.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-8785955474855334935?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/8785955474855334935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2011/05/how-to-access-internet-from-windows.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/8785955474855334935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/8785955474855334935'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2011/05/how-to-access-internet-from-windows.html' title='Browse internet from the Windows mobile device emulator?'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-zWuTOOMDxIg/Tb4pbIgLgBI/AAAAAAAAAOQ/T8p5RBBNjlg/s72-c/1.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-6173223675937310378</id><published>2011-02-19T19:22:00.005+05:30</published><updated>2011-04-14T14:34:13.135+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Graphics'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><category scheme='http://www.blogger.com/atom/ns#' term='GD'/><title type='text'>PHP Image Class</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-exSPqdHxP9c/TV_OvmfSW5I/AAAAAAAAAMA/G5W8SqhLJq4/s1600/x.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="280" src="http://1.bp.blogspot.com/-exSPqdHxP9c/TV_OvmfSW5I/AAAAAAAAAMA/G5W8SqhLJq4/s400/x.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Today I am going to give you something that I have created using PHP. It is a simple PHP class that can be used to manipulate images easily in an object oriented way. I created this by using basic functions in PHP GD library.&lt;/p&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Download&lt;/span&gt;&lt;br /&gt;&lt;p&gt;You can download the ZIP archive containing PHP classes by clicking &lt;a href="http://dl.dropbox.com/u/12594835/blog/php_image_class.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;License&lt;/span&gt;&lt;br /&gt;&lt;p&gt;I would like to distribute this using &lt;a href="http://www.gnu.org/licenses/gpl.txt"&gt;GNU/GPL license&lt;/a&gt;, so you can add more functionality into it and enhance my basic product.&lt;/p&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Functions&lt;/span&gt;&lt;br /&gt;&lt;p&gt;This class allows you to manipulate JPEG, GIF and PNG files. It allows image resizing, cropping, merging, rendering, saving and applying filters.&lt;/p&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Documentation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;Open image&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;i style="background-color: #f3f3f3;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;new Image&lt;/span&gt;(path-to-file)&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="php" name="code"&gt;$img = new Image('/home/user/foo.jpg');&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;You can specify the relative or absolute path as the parameter. Note that this method may throw FileNotFoundException, whenever the method fails to locate the file on the target location. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Resize image&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;i style="background-color: #f3f3f3;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;resize&lt;/span&gt;(width, height, [unit = &lt;span class="Apple-style-span" style="color: red;"&gt;‘px’&lt;/span&gt;, [keep-aspect-ratio = &lt;span class="Apple-style-span" style="color: red;"&gt;false&lt;/span&gt;]])&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="php" name="code"&gt;$img-&amp;gt;resize(800, 600, 'px', true);&lt;/pre&gt;&lt;p&gt;Resize method allows you to resize image file. Unit can be either ‘px’ or ‘%’. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Crop image&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;i style="background-color: #f3f3f3;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;crop&lt;/span&gt;(x, y, width, height)&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="php" name="code"&gt;$img-&amp;gt;crop(100, 50, 600, 500);&lt;/pre&gt;&lt;p&gt;Crop method allows cropping the image. It takes 4 parameters x coordinate, y coordinate, width and the height.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Merge images&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;i style="background-color: #f3f3f3;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;merge&lt;/span&gt;(image-object, [x =&lt;span class="Apple-style-span" style="color: red;"&gt; 0&lt;/span&gt;, [y = &lt;span class="Apple-style-span" style="color: red;"&gt;0&lt;/span&gt;, [opacity = &lt;span class="Apple-style-span" style="color: red;"&gt;100&lt;/span&gt;]]])&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="php" name="code"&gt;$anotherImg = new Image('/home/user/bar.jpg');&lt;br /&gt;$img-&amp;gt;merge($anotherImg, 100, 100, 75);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Merge method can be used to merge to image objects. That means this method results merger of 2 images. Again it takes 4 parameters; Image object, x coordinate, y coordinate and opacity value. Opacity ranges from 0 to 100, which 0 means transparent and 100 means full opaque.&lt;/p&gt;&lt;p&gt;Save image&lt;/p&gt;&lt;p&gt;&lt;i style="background-color: #f3f3f3;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;save&lt;/span&gt;(destination, [file-type = &lt;span class="Apple-style-span" style="color: red;"&gt;‘jpg’&lt;/span&gt;])&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="php" name="code"&gt;$img-&amp;gt;save('/home/user/foo_edit.png', 'png');&lt;/pre&gt;&lt;p&gt;This class can be used to save the resulting image on a storage device. This requires a parameter ‘file-type’ which takes jpg, gif or png as values.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Render image&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;i style="background-color: #f3f3f3;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;render&lt;/span&gt;([file-type = &lt;span class="Apple-style-span" style="color: red;"&gt;‘jpg’&lt;/span&gt;])&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="php" name="code"&gt;$img-&amp;gt;render('gif');&lt;/pre&gt;&lt;p&gt;Render method allows rendering resulting image on the browser without saving it on a storage device. This requires a parameter ‘file-type’ which takes jpg, gif or png as values.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Filters&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Available filters to apply on images are as follows.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;negative&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;grayscale&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;detectEdges&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;emboss&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;gaussianBlur&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;selectiveBlur&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;brightness&lt;/span&gt;(value)&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;contrast&lt;/span&gt;(value)&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;colorize&lt;/span&gt;(r, g, b, [alpha = &lt;span class="Apple-style-span" style="color: red;"&gt;0&lt;/span&gt;])&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;sketchy&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;smooth&lt;/span&gt;(value)&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;sephia&lt;/span&gt;()&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-6173223675937310378?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/6173223675937310378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2011/02/php-image-class.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/6173223675937310378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/6173223675937310378'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2011/02/php-image-class.html' title='PHP Image Class'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-exSPqdHxP9c/TV_OvmfSW5I/AAAAAAAAAMA/G5W8SqhLJq4/s72-c/x.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-3792315495383247345</id><published>2010-08-05T19:40:00.002+05:30</published><updated>2011-04-14T14:24:49.043+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='3D'/><category scheme='http://www.blogger.com/atom/ns#' term='Technology'/><category scheme='http://www.blogger.com/atom/ns#' term='Multimedia'/><category scheme='http://www.blogger.com/atom/ns#' term='How'/><category scheme='http://www.blogger.com/atom/ns#' term='Anaglyph'/><title type='text'>Create your own 3D (Anaglyph) glasses</title><content type='html'>&lt;p&gt;I’m going to deviate from my usual topics today. Let’s consider a small topic in Multimedia. Did you ever tried to create your own 3D glasses for watching 3D movie? If not, today I’m going to tell those steps. If you are not preferred you can buy one around US$ 1 on eBay. But remember, this is so easy and you can create your own one within 15 minutes.&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_iYYoZLJtmKg/TFrH-o5yKHI/AAAAAAAAAJg/J7JLB0L2InY/s1600/1.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="95" src="http://1.bp.blogspot.com/_iYYoZLJtmKg/TFrH-o5yKHI/AAAAAAAAAJg/J7JLB0L2InY/s200/1.jpg" width="200" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Anaglyph Glass&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Before directly jump to our steps, let’s get an idea about this 3D glasses? &lt;/p&gt;&lt;p&gt;There are some videos and images, which provide &lt;b style="color: red;"&gt;stereoscopic 3D effect&lt;/b&gt;. Our naked eyes are not capable of capturing this effect 100%. So we need to use special glasses called, 3D glasses or “&lt;b style="color: red;"&gt;Anaglyph glasses&lt;/b&gt;” to help our brains to understand the effect. These anaglyph images/videos are made up of 2 colored layers, offset with respect to each others, which helps to produce the depth effect.&lt;/p&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_iYYoZLJtmKg/TFrIbKj-fII/AAAAAAAAAJo/_XbpJU1qQXw/s1600/800px-Phallus_impudicus_Stereoimage_Richard_Bartz.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/_iYYoZLJtmKg/TFrIbKj-fII/AAAAAAAAAJo/_XbpJU1qQXw/s320/800px-Phallus_impudicus_Stereoimage_Richard_Bartz.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Sample anaglyph image from Wikipedia (Author: Richard Bartz)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Okay, that’s little bit about the concept. Now it’s working time. Here are the materials we need:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Card board&lt;/li&gt;&lt;li&gt;Template for the glasses. A sketch is available &lt;a href="http://paperproject.org/PDF_files/3dglasses.pdf"&gt;here&lt;/a&gt; and you need to have a print out of it. Or else, you can draw your own one too.&lt;/li&gt;&lt;li&gt;Red and Cyan (Blue) cellophane papers.&lt;/li&gt;&lt;li&gt;And finally the hardest thing, Glue...&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here are the steps:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Cutout the template on the cardboard using the printed (or drawn) sketch.&lt;/li&gt;&lt;li&gt;Cut the cellophane to fit the holes in the template.&lt;/li&gt;&lt;li&gt;Glue or tape them to the holes in the template.&amp;nbsp; (And make sure you put Red cellophane for the left eye and the cyan cellophane for the right eye.)&lt;/li&gt;&lt;li&gt;Now it’s finished creating your own 3D glasses. Enjoy 3D movies and images using your new 3D glasses.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Watch sample 3D video at &lt;a href="http://www.youtube.com/watch?v=-RKI0mtedZw"&gt;http://www.youtube.com/watch?v=-RKI0mtedZw&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-3792315495383247345?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/3792315495383247345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2010/08/create-your-own-3d-anaglyph-glasses.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/3792315495383247345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/3792315495383247345'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2010/08/create-your-own-3d-anaglyph-glasses.html' title='Create your own 3D (Anaglyph) glasses'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_iYYoZLJtmKg/TFrH-o5yKHI/AAAAAAAAAJg/J7JLB0L2InY/s72-c/1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-4646281188701281305</id><published>2010-03-04T11:25:00.001+05:30</published><updated>2011-04-14T14:21:11.314+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Technology'/><category scheme='http://www.blogger.com/atom/ns#' term='Fonts'/><category scheme='http://www.blogger.com/atom/ns#' term='SEO'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>CSS Typography: Using "font-face"</title><content type='html'>&lt;p&gt;One of the main issues involved with web designing is using proper fonts for the interface. That is because in most of times matching fonts for the user interface design are not standard web fonts. Therefore all the users must have the font to view the web properly. Otherwise the default fonts will be displayed.&lt;/p&gt;&lt;p&gt;There are some alternatives to overcome this issue. One of them is using images instead of text. So the images are rendered with the original font, and that will solve our problem. But it is also not issue free. These are the main issues with it.&lt;/p&gt;&lt;p&gt;Images consume more bandwidth than text. Hence it consumes time also.&lt;/p&gt;&lt;p&gt;Search engines are less sensitive for images. They can’t read the content of image and therefore Search Engine Optimization (SEO) will be an issue too.&lt;/p&gt;&lt;p&gt;Hence images are not the best option. There is another alternative, i.e. using CSS &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;font-face&lt;/span&gt;. Font-face is used to define fonts in a style sheet. &lt;/p&gt;&lt;pre class="css" name="code"&gt;@font-face {&lt;br /&gt;      font-family: Bambino;&lt;br /&gt;      src: local("Bambino"), url("Bambino.ttf") format("opentype");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Here, you can specify the source (src) of the font. &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;local&lt;/span&gt; means if the font defined is available in the local PC, then use it. &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;url&lt;/span&gt; means if it is not, download it from the given location. Let’s see how this can use. &lt;/p&gt;&lt;pre class="css" name="code"&gt;/* &lt;br /&gt;      file: styles.css &lt;br /&gt;      "Bambino" is the font I used. "Bambino.ttf" is the relevent font file.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;@font-face {&lt;br /&gt;      font-family: Bambino;&lt;br /&gt;      src: local("Bambino"), url("Bambino.ttf") format("opentype");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;h1 {&lt;br /&gt;      font: bold 28px Bambino;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;p {&lt;br /&gt;      font: 18px Bambino;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;!-- file: font.html --&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;CSS Typography&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;link rel="stylesheet" type="text/css" href="styles.css" /&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;h1&amp;gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit&amp;lt;/h1&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;p&amp;gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras bibendum dui id arcu ornare eu lobortis orci bibendum. Mauris rhoncus tincidunt vestibulum. Duis imperdiet neque sed turpis viverra suscipit gravida est varius. Nullam euismod tellus quis velit semper vitae vehicula ligula congue.&amp;lt;/p&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-4646281188701281305?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/4646281188701281305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2010/03/css-typography-using-font-face.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/4646281188701281305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/4646281188701281305'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2010/03/css-typography-using-font-face.html' title='CSS Typography: Using &quot;font-face&quot;'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-7777885938796935402</id><published>2010-02-24T13:22:00.002+05:30</published><updated>2011-04-14T14:19:30.306+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Technology'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Graphics'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><category scheme='http://www.blogger.com/atom/ns#' term='GD'/><title type='text'>Dynamic progress bar with PHP GD</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_iYYoZLJtmKg/S4TaYSAeRQI/AAAAAAAAAHc/s-P2QM-uOpE/s1600-h/pb1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_iYYoZLJtmKg/S4TaYSAeRQI/AAAAAAAAAHc/s-P2QM-uOpE/s320/pb1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Today I’m going to show you something regarding GD library of PHP. The GD library is the main library using for Graphics in PHP. By using functions of this library, it is possible to manipulate images with PHP.&lt;/p&gt;&lt;p&gt;In this post, I will show you how to create a dynamic progress bar with PHP. In here the “dynamic” means you can parse 2 values, (i.e. maximum value and the current value) and the PHP script will calculate and render the progress bar dynamically on the screen. The output will come in the format of PNG image file. Hence it is very easy to use in you HTML file.&lt;/p&gt;&lt;p&gt;That’s all about the explanation. So let’s go for codes…&lt;/p&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;// filename: progressbar.php&lt;br /&gt;// author  : lasantha samarakoon&lt;br /&gt;&lt;br /&gt;// set the type of data (Content-Type) to PNG image&lt;br /&gt;header("Content-Type: image/png");&lt;br /&gt;&lt;br /&gt;// extract GET global array&lt;br /&gt;extract($_GET);&lt;br /&gt;&lt;br /&gt;// set defaults&lt;br /&gt;if(! isset($max)) $max = 100;&lt;br /&gt;if(! isset($val)) $val = 100;&lt;br /&gt;&lt;br /&gt;// this method prepare blank true color image with given width and height&lt;br /&gt;$im = imagecreatetruecolor(400, 20);&lt;br /&gt;&lt;br /&gt;// set background color (light-blue)&lt;br /&gt;$c_bg = imagecolorallocate($im, 222, 236, 247);&lt;br /&gt;// set foreground color (dark-blue)&lt;br /&gt;$c_fg = imagecolorallocate($im, 27, 120, 179);&lt;br /&gt;&lt;br /&gt;// calculate the width of bar indicator&lt;br /&gt;$val_w = round(($val * 397) / $max);&lt;br /&gt;&lt;br /&gt;// create a rectangle for background and append to the image&lt;br /&gt;imagefilledrectangle($im, 0, 0, 400, 20, $c_bg);&lt;br /&gt;// create a rectangle for the indicator and appent to the image&lt;br /&gt;imagefilledrectangle($im, 2, 2, $val_w, 17, $c_fg);&lt;br /&gt;&lt;br /&gt;// render the image as a PNG&lt;br /&gt;imagepng($im);&lt;br /&gt;&lt;br /&gt;// finally destroy image resources&lt;br /&gt;imagedestroy($im);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;OK… that is the PHP script. Now it’s time to display it in the browser. First create a HTML file to display the image. In the IMG tag of the HTML file, type the location of your PHP script and specify 2 values, maximum and current as follows.&lt;/p&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;Progress Bar&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt; &lt;br /&gt;    &amp;lt;img src="progressbar.php?max=100&amp;amp;val=70" /&amp;gt;&lt;br /&gt; &lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;That’s all, and you can see the output…&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_iYYoZLJtmKg/S4Tael0Q4SI/AAAAAAAAAHk/-ggUC2PeUsg/s1600-h/pb2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_iYYoZLJtmKg/S4Tael0Q4SI/AAAAAAAAAHk/-ggUC2PeUsg/s320/pb2.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-7777885938796935402?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/7777885938796935402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2010/02/dynamic-progress-bar-with-php-gd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/7777885938796935402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/7777885938796935402'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2010/02/dynamic-progress-bar-with-php-gd.html' title='Dynamic progress bar with PHP GD'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_iYYoZLJtmKg/S4TaYSAeRQI/AAAAAAAAAHc/s-P2QM-uOpE/s72-c/pb1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-7827796947363809399</id><published>2009-12-25T12:21:00.002+05:30</published><updated>2011-04-14T14:38:14.322+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='XAMPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><category scheme='http://www.blogger.com/atom/ns#' term='Hosts'/><category scheme='http://www.blogger.com/atom/ns#' term='System'/><title type='text'>Create Virtual Host in XAMPP...</title><content type='html'>&lt;p&gt;XMAPP is one of the main easy to install Apache distribution which containing MySQL, PHP, Mercury Mail Transport System, Filezilla and etc. And this package is available for many operating systems such as Microsoft Windows, Linux, Mac OS X and Solaris. And the good thing is it’s a freeware. So you can download it free of charge from here.&lt;/p&gt;&lt;p&gt;If you want to use XAMPP, you need to host your web pages and files in XAMPP web folder, which is known as “&lt;span style="color: red;"&gt;htdocs&lt;/span&gt;”. You can access this folder throw your browser by typing &lt;a href="http://localhost/"&gt;http://localhost&lt;/a&gt; in the address bar. So instead of that today I am going to show you how to create another directory in your hard drive and host it in XAMPP. Steps are as follows.&lt;/p&gt;&lt;p&gt;Create a folder in your HD which is going to use as the root directory. As an example I will create a directory in the &lt;span style="color: red;"&gt;D:\Virtual\myroot\&lt;/span&gt;. So “&lt;span style="color: red;"&gt;myroot&lt;/span&gt;” will be my new root directory.&lt;/p&gt;&lt;p&gt;1. Open XAMPP installed directory.&lt;/p&gt;&lt;p&gt;2. Go to &lt;span style="color: red;"&gt;apache &lt;/span&gt;-&amp;gt; &lt;span style="color: red;"&gt;conf &lt;/span&gt;-&amp;gt; &lt;span style="color: red;"&gt;extra &lt;/span&gt;directory.&lt;/p&gt;&lt;p&gt;3. In the extra directory there is a file called “&lt;span style="color: #cc0000;"&gt;httpd-vhosts.conf&lt;/span&gt;”. Open it in text editor such as NOTEPAD.&lt;/p&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;VirtualHost 127.0.0.1:80&amp;gt;&lt;br /&gt;    DocumentRoot "D:/Virtual/myroot/"&lt;br /&gt;    ServerName myroot.example.com&lt;br /&gt;    &amp;lt;Directory D:/Virtual/myroot/&amp;gt;&lt;br /&gt;        Options Indexes FollowSymLinks&lt;br /&gt;        AllowOverride All&lt;br /&gt;        Order allow,deny&lt;br /&gt;        Allow from all&lt;br /&gt;    &amp;lt;/Directory&amp;gt;&lt;br /&gt;&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;4. Save and close the file.&lt;/p&gt;&lt;p&gt;5. Now go to the "&lt;span style="color: red;"&gt;Windows&lt;/span&gt;" folder. Open &lt;span style="color: red;"&gt;System32 &lt;/span&gt;-&amp;gt; &lt;span style="color: red;"&gt;drivers &lt;/span&gt;-&amp;gt; &lt;span style="color: red;"&gt;etc &lt;/span&gt;folder.&lt;/p&gt;&lt;p&gt;6. In the “&lt;span style="color: red;"&gt;etc&lt;/span&gt;” directory, there is a file called “&lt;span style="color: #cc0000;"&gt;hosts&lt;/span&gt;”. Open it in a text editor.&lt;/p&gt;&lt;p&gt;7. At the end of the file append following text.&lt;/p&gt;&lt;pre class="xml" name="code"&gt;127.0.0.1    myroot.example.com&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;8. Save and close the file. Sometimes your anti-virus program will block saving. In that kind of situation, allow it.&lt;/p&gt;&lt;p&gt;9. Go to “&lt;b&gt;XAMPP Control Panel&lt;/b&gt;” and stop and restart the Apache service.&lt;/p&gt;&lt;p&gt;10. Open your preferred browser and type &lt;a href="http://myroot.example.com/"&gt;http://myroot.example.com/&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;11. You can see the content of you new virtual host.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-7827796947363809399?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/7827796947363809399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2009/12/create-virtual-host-in-xampp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/7827796947363809399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/7827796947363809399'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2009/12/create-virtual-host-in-xampp.html' title='Create Virtual Host in XAMPP...'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-6369628557960355580</id><published>2009-11-21T15:20:00.001+05:30</published><updated>2011-04-14T12:58:52.589+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Technology'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='PEAR'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><title type='text'>PEAR: An Introduction...</title><content type='html'>&lt;p&gt;Today I’m gonna say you about something popular among the PHP developers. So that’s called PEAR. I hope you guys may be heard about PEAR. PEAR is an acronym for &lt;b&gt;PHP Extension and Application Repository&lt;/b&gt;. PEAR is a framework or collection of PHP classes which allow us to use them in our solutions. Official web site of PEAR can be found on &lt;a href="http://pear.php.net/"&gt;http://pear.php.net&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;As I told you that PEAR is a collection of classes or components. So what are the components available in PEAR?&amp;nbsp; It has many more components such as Database, File system, Graphics and Image Processing, Mail, Math, Structures and etc. So today I’m going to show you how to use Database component of PEAR.&lt;/p&gt;&lt;span style="font-size: large;"&gt;PEAR Database:&lt;/span&gt;&lt;br /&gt;&lt;p&gt;In most of web developing solutions, PHP developers use databases to store data. So the backend database management system can be MySQL, PostgreSQL, SQLite, etc. There are different commands available in PHP to handle each and every database types. What will happen when you want to shift from MySQL to PgSQL? This will result you to change all the PHP MySQL commands to PHP PgSQL commands. In this kind of changing environment, it is advisable to use a framework such as PEAR.&lt;/p&gt;&lt;p&gt;Using PEAR, you can handle many DBMSs without changing the code. It is something like a common API set. The only part you have to change when you want to shift is the connection string.&lt;/p&gt;&lt;p&gt;OK… Let’s consider about the example. In this example, I will connect to a MySQL database, fetch some data and display them on the web page. First you need to create the database as follows.&lt;/p&gt;&lt;pre class="sql" name="code"&gt;CREATE DATABASE test;&lt;br /&gt;USE DATABASE test;&lt;br /&gt;CREATE TABLE users(&lt;br /&gt;    uname VARCHAR(20) NOT NULL,&lt;br /&gt;    pword VARCHAR(20) NOT NULL&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;That’s all. Then the PHP code is as follows. I’ll explain them later.&lt;/p&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;// peardb_ex.php&lt;br /&gt;require_once 'DB.php';&lt;br /&gt;&lt;br /&gt;// connect to the database&lt;br /&gt;$db = DB::connect('mysql://root:rootpass@localhost/test');&lt;br /&gt;&lt;br /&gt;// check for errors&lt;br /&gt;if(DB::isError($db)) {&lt;br /&gt;    echo "Unable to connect to the database: " . $db-&amp;gt;getMessage();&lt;br /&gt;}else {&lt;br /&gt;&lt;br /&gt;    // execute the query&lt;br /&gt;    $sql = "select * from users";&lt;br /&gt;    $res = $db-&amp;gt;query($sql);&lt;br /&gt;&lt;br /&gt;    // get number of rows affected&lt;br /&gt;    $num_res = $res-&amp;gt;numRows();&lt;br /&gt;&lt;br /&gt;    echo "&amp;lt;b&amp;gt;$num_res users&amp;lt;/b&amp;gt;&amp;lt;hr /&amp;gt;&amp;lt;hr /&amp;gt;";&lt;br /&gt;&lt;br /&gt;    // travers the resultset&lt;br /&gt;    while($r = $res-&amp;gt;fetchRow(DB_FETCHMODE_ASSOC)) {&lt;br /&gt;&lt;br /&gt;        echo "username: " . $r['uname'] . "&amp;lt;br /&amp;gt;";&lt;br /&gt;        echo "password: " . $r['pword'] . "&amp;lt;br /&amp;gt;";&lt;br /&gt;        echo "&amp;lt;hr /&amp;gt;";&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // free resultset&lt;br /&gt;    $res-&amp;gt;free();&lt;br /&gt;&lt;br /&gt;    // close the connection&lt;br /&gt;    $db-&amp;gt;disconnect();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre class="php" name="code"&gt;require_once 'DB.php';&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This is the file that has definitons for PEAR database component. It's available in the PEAR installation folder, so you need not to copy it to the local directory.&lt;/p&gt;&lt;pre class="php" name="code"&gt;$db = DB::connect('mysql://root:rootpass@localhost/test');&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This is how the connection will be established. The connection string can be specify as, &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Driver://username:password@host/database&lt;/span&gt;. If you want to shift from MySQL to PgSQL, the only thing you need to do is change the connection string to, &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pgsql://root:rootpass@localhost/test&lt;/span&gt;. Other commands will remain unchanged.&lt;/p&gt;&lt;pre class="php" name="code"&gt;DB::isError($db);&lt;br /&gt;&lt;/pre&gt;This is used to check if any error occurred.&lt;br /&gt;&lt;pre class="php" name="code"&gt;$sql = "select * from users";&lt;br /&gt;$res = $db-&amp;gt;query($sql);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This is the command used to execute SQL query against the database. (Same like &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$res = mysql_query($sql)&lt;/span&gt;)&lt;/p&gt;&lt;pre class="php" name="code"&gt;$num_res = $res-&amp;gt;numRows();&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Get number of rows returned by the query.&lt;/p&gt;&lt;pre class="php" name="code"&gt;while($r = $res-&amp;gt;fetchRow(DB_FETCHMODE_ASSOC)) {&lt;br /&gt;&lt;br /&gt;    echo "username: " . $r['uname'] . "&amp;lt;br /&amp;gt;";&lt;br /&gt;    echo "password: " . $r['pword'] . "&amp;lt;br /&amp;gt;";&lt;br /&gt;    echo "&amp;lt;hr /&amp;gt;";&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;This loop is used to travers the resultset. It is same as &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;mysql_fetch_assoc($res)&lt;/span&gt;.&lt;/p&gt;&lt;pre class="php" name="code"&gt;$res-&amp;gt;free();&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Free the resultset.&lt;/p&gt;&lt;pre class="php" name="code"&gt;$db-&amp;gt;disconnect();&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Close the connection.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-6369628557960355580?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/6369628557960355580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2009/11/pear-introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/6369628557960355580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/6369628557960355580'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2009/11/pear-introduction.html' title='PEAR: An Introduction...'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6770910695892884019.post-1438256789356869672</id><published>2009-11-15T18:49:00.012+05:30</published><updated>2011-04-14T12:55:52.723+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='Technology'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>AJAX File Download</title><content type='html'>&lt;p&gt;Good day guys, today I’m going to show you how to download a file without reloading or refreshing the current page. So to do that, I will use my preferred server-side language PHP, HTML and little bit of CSS.&lt;/p&gt;&lt;p&gt;So the problem is, I have a link named “Download” and when I click on that link browser’s file download box should be visible without refreshing or navigating away from the page. So to solve this problem I will use an AJAX technique. Let’s think how we can implement this in AJAX.&lt;/p&gt;&lt;p&gt;My solution is this. I will create a HTML inner frame in my web page. And when I click on the download link, something will be loaded in the inner frame. So this is how I solved that.&lt;/p&gt;&lt;p&gt;I will create 2 web pages, one is pure HTML and other one is PHP. The HTML page contains the inner frame and download button. The PHP file is used to dynamically read the content of the downloadable file and write them to the client.&lt;/p&gt;&lt;pre class="html" name="code"&gt;&amp;lt;!-- index.htm --&amp;gt;  &lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;  &lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;AJAX Download&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- this inner frame is hidden by css --&amp;gt;&lt;br /&gt;&amp;lt;iframe name="ajax_frame" style="display: none;"&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- download link --&amp;gt;&lt;br /&gt;&amp;lt;a href="download.php" target="ajax_frame"&amp;gt;Download&amp;lt;/a&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Here I named inner frame as “ajax_frame” and in the link I set the target to that inner frame. So when I click on the link, the content will be loaded in the inner frame. And I set the display style of the inner frame to “none” to hide the frame in the web page. So the user cannot see the inner work of the web page.&lt;/p&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php // download.php  &lt;br /&gt;// send http header 'content-type'&lt;br /&gt;header("Content-Type: text/plain");  &lt;br /&gt;&lt;br /&gt;// start flushing data  &lt;br /&gt;ob_start();  &lt;br /&gt;&lt;br /&gt;// echo data  &lt;br /&gt;echo "hello world";  &lt;br /&gt;&lt;br /&gt;// get the flushed data size and send http header attribute 'content-length'  &lt;br /&gt;header("Content-Length: " . ob_get_length());  &lt;br /&gt;&lt;br /&gt;// send http header information regarding the file attachment  &lt;br /&gt;header("Content-Disposition: attachment; filename=test.txt; modification-date=\"Sun, 15 Nov 2009 12:50:00 +0530\";");  &lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Above is the technique I used to push the file content to the client. It’s just a PHP echo with some header commands. In this demonstration I did not used any external file, but I send some content using the echo command. This is really same as reading a text file contents “hello world” in it. Let’s consider line by line.&lt;/p&gt;&lt;pre class="php" name="code"&gt;header("Content-Type: text/plain");&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;I used header command to send HTTP response headers to the client. Here I send “Content-Type” header indicating the incoming data is belongs to plain text. You can use any other Content-Type regarding to the data you are going to send. As an example, for a PDF file you can send “application/pdf”.&lt;/p&gt;&lt;p&gt;&lt;pre class="php" name="code"&gt;ob_start();&lt;br /&gt;&lt;/pre&gt;Start flushing data to the client.&lt;/p&gt;&lt;pre class="php" name="code"&gt;echo "hello world";&lt;/pre&gt;&lt;p&gt;Echo the content of the file.&lt;/p&gt;&lt;pre class="php" name="code"&gt;header("Content-Length: " . ob_get_length());&lt;/pre&gt;&lt;p&gt;Get the length of data flushed to the client and send the header “Content-Length” to the client.&lt;/p&gt;&lt;pre class="php" name="code"&gt;header("Content-Disposition: attachment; filename=test.txt; modification-date=\"Sun, 15 Nov 2009 12:50:00 +0530\";");&lt;/pre&gt;&lt;p&gt;Here it is again an HTTP response header, indicating that the flushed data belongs to the file named “test.txt” and the modified date of the file.&lt;/p&gt;&lt;p&gt;So this is all about the solution. If you want to send really an external file to the user, you have to replace line # 9 with commands regarding to open the file, read the content, echo the content and close the file. That’s all.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6770910695892884019-1438256789356869672?l=lasa-talkz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lasa-talkz.blogspot.com/feeds/1438256789356869672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lasa-talkz.blogspot.com/2009/11/good-day-guys-today-im-going-to-show.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/1438256789356869672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6770910695892884019/posts/default/1438256789356869672'/><link rel='alternate' type='text/html' href='http://lasa-talkz.blogspot.com/2009/11/good-day-guys-today-im-going-to-show.html' title='AJAX File Download'/><author><name>Lasantha Samarakoon</name><uri>http://www.blogger.com/profile/08599298334105971015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_iYYoZLJtmKg/SwAPdtWbfCI/AAAAAAAAACw/4KP3-OmXfKI/S220/06072007658.jpg'/></author><thr:total>0</thr:total></entry></feed>
