<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Image Organiser Developers Blog</title>
	<atom:link href="http://itc570af.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://itc570af.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 24 May 2010 10:27:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='itc570af.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Image Organiser Developers Blog</title>
		<link>http://itc570af.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://itc570af.wordpress.com/osd.xml" title="Image Organiser Developers Blog" />
	<atom:link rel='hub' href='http://itc570af.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Project Blog Conclusion</title>
		<link>http://itc570af.wordpress.com/2010/05/24/project-blog-conclusion/</link>
		<comments>http://itc570af.wordpress.com/2010/05/24/project-blog-conclusion/#comments</comments>
		<pubDate>Mon, 24 May 2010 10:27:54 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Project Conclusion]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=62</guid>
		<description><![CDATA[This has been a challenging project, but it has been a great learning process. A need at my workplace gave me a purposeful project to work on which provided the motivation to develop web scripts, which is something that I have not had much experience in. I greatly underestimated the time required to complete the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=62&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This has been a challenging project, but it has been a great learning process. A need at my workplace gave me a purposeful project to work on which provided the motivation to develop web scripts, which is something that I have not had much experience in.</p>
<p>I greatly underestimated the time required to complete the project, which is why I completed the components but was unable to tie them all together in the given time. With this being a project for my employer, I will continue to work on the project in coming weeks. At the moment my main focus at work is on another project, which is the implementation of a new version of our ERP system. After months of testing we went live with it today, which turned out to be relatively successful. My focus over the next week or 2 will be to fix some of the smaller problems, and to prepare for the exam in my other subject.</p>
<p>When I complete the work on the Image Organiser Application, I will post a final update here on the blog.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=62&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/24/project-blog-conclusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Plan</title>
		<link>http://itc570af.wordpress.com/2010/05/24/project-plan/</link>
		<comments>http://itc570af.wordpress.com/2010/05/24/project-plan/#comments</comments>
		<pubDate>Mon, 24 May 2010 10:17:47 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[Project Outline]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=58</guid>
		<description><![CDATA[The project timeline below should have been added much earlier in the project, but I overlooked it. I have included it now to give an overview of the development process.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=58&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The project timeline below should have been added much earlier in the project, but I overlooked it. I have included it now to give an overview of the development process.</p>
<p><a href="http://itc570af.files.wordpress.com/2010/05/project-plan.jpg"><img class="alignleft size-full wp-image-59" title="project plan" src="http://itc570af.files.wordpress.com/2010/05/project-plan.jpg?w=450&#038;h=133" alt="" width="450" height="133" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=58&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/24/project-plan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/05/project-plan.jpg" medium="image">
			<media:title type="html">project plan</media:title>
		</media:content>
	</item>
		<item>
		<title>Resizing Images With PHP</title>
		<link>http://itc570af.wordpress.com/2010/05/23/resizing-images-with-php/</link>
		<comments>http://itc570af.wordpress.com/2010/05/23/resizing-images-with-php/#comments</comments>
		<pubDate>Sun, 23 May 2010 10:16:02 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[image resize]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=53</guid>
		<description><![CDATA[Resizing images is actually quite easy. I completed this piece of code much quicker than the previous few. I do find PHP much easier to code with the JavaScript or JQuery though, so that could have something to do with it. I have enabled some output in the script to show what the variable values [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=53&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Resizing images is actually quite easy. I completed this piece of code much quicker than the previous few. I do find PHP much easier to code with the JavaScript or JQuery though, so that could have something to do with it. I have enabled some output in the script to show what the variable values are set to. In order to integrate the code into my HTML, JavaScript and JQuery I need to set the variables $imagetoresize and $imageresized to POST inputs.</p>
<p>&lt;?php</p>
<p>$imagetoresize = &#8220;imageorg/test.jpg&#8221;;<br />
$imageresized = &#8220;imageorg/resized/test.jpg&#8221;;<br />
$newdimension = &#8220;400&#8243;;<br />
$newaxis = &#8220;w&#8221;;</p>
<p>list($currentwidth, $currentheight) = getimagesize($imagetoresize);</p>
<p>echo &#8220;width &#8220;, $currentwidth, &#8220;, height &#8220;, $currentheight, &#8220;&lt;P&gt;&#8221;;</p>
<p>if ($newaxis==&#8221;w&#8221;)<br />
 $ratio=($newdimension/$currentwidth);<br />
else<br />
 $ratio=($newdimension/$currentheight);<br />
echo &#8220;ratio &#8220;, $ratio, &#8220;&lt;P&gt;&#8221;;</p>
<p>$newwidth = $currentwidth * $ratio;<br />
$newheight = $currentheight * $ratio;<br />
echo &#8220;new width &#8220;, $newwidth, &#8221; new height &#8220;, $newheight, &#8220;&lt;P&gt;&#8221;;</p>
<p>$outputfile = imagecreatetruecolor($newwidth, $newheight);<br />
$inputfile = imagecreatefromjpeg($imagetoresize);</p>
<p>imagecopyresampled($outputfile, $inputfile, 0, 0, 0, 0, $newwidth, $newheight, $currentwidth, $currentheight);</p>
<p>imagejpeg($outputfile, $imageresized, 100);</p>
<p>echo $imagetoresize, &#8221; resized to &#8220;, $newwidth, &#8221; * &#8220;, $newheight, &#8221; in output file &#8220;, $imageresized;<br />
?&gt;</p>
<p>After running this script, I can confirm that the file imageorg/resized/test.jpg was created. The screenshot below shows the value of the variables from the script after I deleted the file and re-run the script.</p>
<p><a href="http://itc570af.files.wordpress.com/2010/05/wk9-1.jpg"><img class="alignleft size-full wp-image-54" title="wk9-1" src="http://itc570af.files.wordpress.com/2010/05/wk9-1.jpg?w=450&#038;h=207" alt="" width="450" height="207" /></a></p>
<p>The next job is to tie all of the pieces together into one screen, and then debug after end user testing. Due to high priority projects at work, I was not able to arrange the testing during the course of this project.</p>
<p><strong>References</strong></p>
<p>PHP: getimagesize &#8211; Manual (2010). Retrieved 23rd May 2010 from <a href="http://php.net/manual/en/function.getimagesize.php">http://php.net/manual/en/function.getimagesize.php</a></p>
<p>PHP: imagecopyresampled &#8211; Manual (2010). Retrieved 23rd May 2010 from <a href="http://php.net/manual/en/function.imagecopyresampled.php">http://php.net/manual/en/function.imagecopyresampled.php</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=53&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/23/resizing-images-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/05/wk9-1.jpg" medium="image">
			<media:title type="html">wk9-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Renaming Files With AJAX and PHP</title>
		<link>http://itc570af.wordpress.com/2010/05/20/renaming-files-with-ajax-and-php/</link>
		<comments>http://itc570af.wordpress.com/2010/05/20/renaming-files-with-ajax-and-php/#comments</comments>
		<pubDate>Thu, 20 May 2010 10:53:32 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rename File]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=49</guid>
		<description><![CDATA[Now we get into some of the impressive functionality of AJAX. We are going to submit a HTML form to a PHP script using AJAX in order to get the new filename from the user and rename the file. I got this working last night, but i my haste at another test run of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=49&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now we get into some of the impressive functionality of AJAX. We are going to submit a HTML form to a PHP script using AJAX in order to get the new filename from the user and rename the file. I got this working last night, but i my haste at another test run of the application I thought it wasn&#8217;t working and deleted my code. Below we have the code for a plain old boring HTML form:</p>
<p>&lt;div id=&#8221;rename_form&#8221;&gt; <br />
&lt;form id=&#8221;rename&#8221; method=&#8221;POST&#8221; action=&#8221;imageorgrename.php&#8221;&gt; <br />
    &lt;input type=&#8221;text&#8221; name=&#8221;newfilename&#8221; id=&#8221;newfilename&#8221;&gt; <br />
    &lt;input type=&#8221;submit&#8221; value=&#8221;submit&#8221;&gt; <br />
&lt;/form&gt; <br />
&lt;/div&gt; </p>
<p>Now we will add a little spice in the way that we submit the form &#8211; AJAX is hot!</p>
<p>$(function(){<br />
    $(&#8220;#rename&#8221;).submit(function(){<br />
//        dataString = $(&#8220;#rename&#8221;).serialize();</p>
<p>        $.ajax({<br />
        type: &#8220;POST&#8221;,<br />
        url: &#8220;imageorgrename.php&#8221;,<br />
        data: dataString,<br />
        dataType: &#8220;json&#8221;,<br />
        success: function(data) {<br />
        }</p>
<p>        });</p>
<p>        return false;           </p>
<p>    });<br />
});</p>
<p>This code submits the dataString I created previously (oldfilename, newfilename) using POST to the script imageorgrename.php using a dataType of JSON. JSON is the JavaScript Object Notation, a lightweight data interchange format that is language-independent. It uses name / value pairs known as objects and ordered lists of values known as arrays (JSON, n.d. paragraph 1-2). The result is returned without any page refresh. The application in use is shown below and on checking the imageorg folder, the file had been renamed.</p>
<p><a href="http://itc570af.files.wordpress.com/2010/05/wk8-1.jpg"><img class="alignleft size-full wp-image-50" title="wk8-1" src="http://itc570af.files.wordpress.com/2010/05/wk8-1.jpg?w=431&#038;h=505" alt="" width="431" height="505" /></a></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>References</strong></p>
<p>JSON (n.d.). Retrieved 20th May 2010 from <a href="http://www.json.org/">http://www.json.org/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=49&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/20/renaming-files-with-ajax-and-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/05/wk8-1.jpg" medium="image">
			<media:title type="html">wk8-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting an Input Variable Into JQuery</title>
		<link>http://itc570af.wordpress.com/2010/05/18/getting-an-input-variable-into-jquery/</link>
		<comments>http://itc570af.wordpress.com/2010/05/18/getting-an-input-variable-into-jquery/#comments</comments>
		<pubDate>Tue, 18 May 2010 11:16:38 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[HTML forms]]></category>
		<category><![CDATA[Input Variable]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Rename File]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=45</guid>
		<description><![CDATA[In my last modification I got the current image filename being displayed as a variable. Now I need to get the new filename from the application user and assign it to a variable. I spent a couple of hours unsuccessfully tinkering with my JQuery and a new DIV last night, but I finally found out [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=45&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my last modification I got the current image filename being displayed as a variable. Now I need to get the new filename from the application user and assign it to a variable. I spent a couple of hours unsuccessfully tinkering with my JQuery and a new DIV last night, but I finally found out how to do it by using a named INPUT in my DIV, and using JQuery&#8217;s .val attribute (Hope, 2010, paragraph 2).</p>
<p>My code for the DIV is below:</p>
<p>&lt;div id=&#8221;form1&#8243;&gt;<br />
 &lt;input name=&#8221;newfname&#8221; id=&#8221;newfname&#8221; type=&#8221;text&#8221;&gt;<br />
&lt;/div&gt;</p>
<p>In my JQuery code I have the following:</p>
<p>var newfilename = $(&#8220;#newfname&#8221;).val();<br />
alert(newfilename);</p>
<p>Now when I browse to <a href="http://localhost:8080/imageorgjq.html">http://localhost:8080/imageorgjq.html</a> I get the screen below after typing a new filename for the first file.</p>
<p><a href="http://itc570af.files.wordpress.com/2010/05/wk7-1.jpg"><img class="alignleft size-full wp-image-46" title="wk7-1" src="http://itc570af.files.wordpress.com/2010/05/wk7-1.jpg?w=450&#038;h=388" alt="" width="450" height="388" /></a></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>I am not renaming the file yet. I need PHP to do this. I will determine where and how to do this in the next short post as I think it will be a 1 line call from my JQuery and 1 line of code in a PHP script.</p>
<p><strong>References</strong></p>
<p>Hope, C. (2010). How to Get and Set Form Element Values With JQuery. Retrieved 18th May 2010 from <a href="http://www.electrictoolbox.com/jquery-get-set-form-values/">http://www.electrictoolbox.com/jquery-get-set-form-values/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=45&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/18/getting-an-input-variable-into-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/05/wk7-1.jpg" medium="image">
			<media:title type="html">wk7-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting the Current Filename as a Variable</title>
		<link>http://itc570af.wordpress.com/2010/05/14/getting-the-current-filename-as-a-variable/</link>
		<comments>http://itc570af.wordpress.com/2010/05/14/getting-the-current-filename-as-a-variable/#comments</comments>
		<pubDate>Fri, 14 May 2010 12:23:22 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[.attr]]></category>
		<category><![CDATA[.text]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[href]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=42</guid>
		<description><![CDATA[You would think that getting an attribute of the current object would be simple. Well it is, but it took me a long time to get there. I broke my imageorgjq.html file countless times in attempts to get the filename of the current image as a variable. To display the value of the variable, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=42&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You would think that getting an attribute of the current object would be simple. Well it is, but it took me a long time to get there. I broke my imageorgjq.html file countless times in attempts to get the filename of the current image as a variable. To display the value of the variable, I created a new DIV below the current image as below:</p>
<p>&lt;div id=&#8221;fname&#8221;&gt;<br />
Filename<br />
&lt;/div&gt;</p>
<p>The key to getting the filename is the attribute &#8220;href&#8221;, so I created the variable arrayval as below:</p>
<p>var arrayval = $(&#8220;#thumbnails a.active&#8221;).attr(&#8220;href&#8221;);</p>
<p>I had several failed attempts at getting this to work, so I added the line below to display the current value of &#8220;arrayval&#8221;, which resulted in a popup alert:</p>
<p>//alert(arrayval);</p>
<p>Once I was getting the correct value into my variable, I used the line below to write it to the DIV that I created earlier:</p>
<p>$(&#8220;#fname&#8221;).text(arrayval);</p>
<p>I was using the append function at first, which was adding the current filename to what was already in the DIV. I then found the forum posting by Daniel Papasian (2008) as referenced below, which contained the simple &#8220;text&#8221; function to replace the existing content of a DIV. Chris Hope&#8217;s &#8220;Electrictoolbox&#8221; website (2009) was also useful as it helped with being able to get the value of the current object.</p>
<p>In summary, the following are the 2 pieces of code I have added to imageorgjq.html:</p>
<p>var arrayval = $(&#8220;#thumbnails a.active&#8221;).attr(&#8220;href&#8221;);<br />
//alert(arrayval);<br />
$(&#8220;#fname&#8221;).text(arrayval);</p>
<p>&lt;div id=&#8221;fname&#8221;&gt;<br />
Filename<br />
&lt;/div&gt;</p>
<p>The alert can be removed.</p>
<p><strong>References</strong></p>
<p>Papasian, D. (2008). Replace Text Inside a DIV Element. Retrieved 14th May 2010 from <a href="http://stackoverflow.com/questions/121817/replace-text-inside-a-div-element">http://stackoverflow.com/questions/121817/replace-text-inside-a-div-element</a></p>
<p>Hope, C. (2009). Use append() to Add Text / HTML to an Element With JQuery. Retrieved 14th May 2010 from <a href="http://www.electrictoolbox.com/jquery-append-add-text-to-element/">http://www.electrictoolbox.com/jquery-append-add-text-to-element/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=42&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/14/getting-the-current-filename-as-a-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>
	</item>
		<item>
		<title>Displaying the Images</title>
		<link>http://itc570af.wordpress.com/2010/05/14/displaying-the-images/</link>
		<comments>http://itc570af.wordpress.com/2010/05/14/displaying-the-images/#comments</comments>
		<pubDate>Fri, 14 May 2010 11:53:55 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Display Images]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=36</guid>
		<description><![CDATA[I have just found that I left this posting as a draft but did not post it. So below is what I was working on earlier this week. I got a little lost and confused while trying to get the image import working with JQuery. Now that I have put that on the shelf for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=36&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have just found that I left this posting as a draft but did not post it. So below is what I was working on earlier this week.</p>
<p>I got a little lost and confused while trying to get the image import working with JQuery. Now that I have put that on the shelf for now and done a simple image import I have new focus to get on with displaying and modifying the image files.</p>
<p>I am now going to use HTML DIV&#8217;s to display the current image, the previous and next buttons, and the thumbnail images. The thumbnail images won&#8217;t be thumbnails in the usual sense. They will be the same size as the current image, but are used as a reference within the array of images.</p>
<p>The following code will be integrated into the application at a later time, after testing has been done.</p>
<p>&lt;HTML&gt;<br />
&lt;HEAD&gt;<br />
&lt;script src=&#8221;jquery.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<p>$(document).ready(function(){<br />
 // show the large version of this thumbnail<br />
 $(&#8220;#thumbnails a&#8221;).click(function(e){<br />
   <br />
 // clear current active thumbnail<br />
 $(&#8220;#imagetoedit&#8221;).attr(&#8220;src&#8221;, this.href);<br />
 <br />
 // mark this thumbnail as active<br />
 var $thumbnails = $(this).siblings().removeClass(&#8220;active&#8221;);<br />
 <br />
 // setup next and previous buttons. we may not use previous<br />
 //but set it up in case<br />
 $(this).addClass(&#8220;active&#8221;);</p>
<p> var arrayposition = $thumbnails.index(this);<br />
 $(&#8220;#next&#8221;).attr(&#8220;disabled&#8221;, arrayposition==$thumbnails.length-1);<br />
 $(&#8220;#prev&#8221;).attr(&#8220;disabled&#8221;, arrayposition==0);<br />
 return false;<br />
});</p>
<p>// next/prev buttons just click the next/prev thumb when enabled</p>
<p>$(&#8220;#prev&#8221;).click(function(){<br />
  $(&#8220;#thumbnails a.active&#8221;).prev().click();<br />
});</p>
<p>$(&#8220;#next&#8221;).click(function(){<br />
 $(&#8220;#thumbnails a.active&#8221;).next().click();<br />
});</p>
<p>// select the first thumbnail<br />
$(&#8220;#thumbnails a:first&#8221;).click();<br />
});<br />
&lt;/script&gt;<br />
&lt;/HEAD&gt;<br />
&lt;BODY&gt;<br />
&lt;div&gt;<br />
  &lt;img id=&#8221;imagetoedit&#8221; src=&#8221;imageorg/wk1-1.jpg&#8221;&gt;<br />
&lt;/div&gt;<br />
&lt;div id=&#8221;nav&#8221;&gt;<br />
  &lt;button id=&#8221;prev&#8221;&gt;Prev&lt;/button&gt;<br />
  &lt;button id=&#8221;next&#8221;&gt;Next&lt;/button&gt;<br />
&lt;/div&gt;<br />
&lt;div id=&#8221;thumbnails&#8221;&gt;<br />
  &lt;a href=&#8221;imageorg/wk1-1.jpg&#8221;&gt;&lt;img src=&#8221;imageorg/wk1-1.jpg&#8221;&gt;&lt;/a&gt;<br />
  &lt;a href=&#8221;imageorg/wk2-1.jpg&#8221;&gt;&lt;img src=&#8221;imageorg/wk2-1.jpg&#8221;&gt;&lt;/a&gt;<br />
  &lt;a href=&#8221;imageorg/wk3-1.jpg&#8221;&gt;&lt;img src=&#8221;imageorg/wk3-1.jpg&#8221;&gt;&lt;/a&gt;<br />
&lt;/div&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</p>
<p>When I browse to <a href="http://localhost:8080/imageorgjq.html">http://localhost:8080/imageorgjq.html</a>, I get the page below:</p>
<p><a href="http://itc570af.files.wordpress.com/2010/05/wk6-1.jpg"><img class="alignleft size-full wp-image-37" title="wk6-1" src="http://itc570af.files.wordpress.com/2010/05/wk6-1.jpg?w=450&#038;h=272" alt="" width="450" height="272" /></a></p>
<p>As you can see, the &#8220;thumbnail images are also being displayed. To fix this, I added the following line directly after $(document).ready(function(){</p>
<p>$(&#8216;#thumbnails).hide();</p>
<p>On testing, this did hide the DIV as expected so we only see the active image on the screen along with the &#8220;Next&#8221; and &#8220;Prev&#8221; buttons. I am now starting to see significant savings in the amount of code I need to write by using JQuery.</p>
<p><strong>References</strong></p>
<p>.hide() &#8211; JQuery API (n.d.). Retrieved7th May 2010 from <a href="http://api.jquery.com/hide/">http://api.jquery.com/hide/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=36&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/14/displaying-the-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/05/wk6-1.jpg" medium="image">
			<media:title type="html">wk6-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Back to Basics</title>
		<link>http://itc570af.wordpress.com/2010/05/05/back-to-basics/</link>
		<comments>http://itc570af.wordpress.com/2010/05/05/back-to-basics/#comments</comments>
		<pubDate>Wed, 05 May 2010 12:20:40 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=33</guid>
		<description><![CDATA[I have been struggling for the past 10 days or so trying to get a working file upload script using JQuery. This appears to be quite difficult with multiple files. I have decided to go back to basics and start with a simple file upload script using a HTML form and PHP. I will then [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=33&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been struggling for the past 10 days or so trying to get a working file upload script using JQuery. This appears to be quite difficult with multiple files.</p>
<p>I have decided to go back to basics and start with a simple file upload script using a HTML form and PHP. I will then move onto displaying and renaming the images one at a time. If time permits, I will come back to the file upload problem. Otherwise I will have to fininsh this after the semester has finished, as it is afterall a work-related project.</p>
<p>I have created a new HTML file called imageorg.html with the code below:</p>
<p>&lt;HTML&gt;<br />
 &lt;form enctype=&#8221;multipart/form-data&#8221; action=&#8221;imageorgupload.php&#8221; method=&#8221;POST&#8221;&gt;<br />
  Select a file to upload: &lt;input name=&#8221;uploaded&#8221; type=&#8221;file&#8221;&gt;<br />
  &lt;br&gt;<br />
  &lt;input type=&#8221;submit&#8221; value=&#8221;Import&#8221;&gt;<br />
 &lt;/form&gt;<br />
&lt;/HTML&gt;</p>
<p>The form is processed by the PHP script as below:</p>
<p>&lt;?php<br />
 //Set the upload directory<br />
 $imagesdir = &#8220;imageorg/&#8221;;<br />
 $imagesdir = $imagesdir . basename( $_FILES['uploaded']['name']) ;<br />
 //Get the filename<br />
 $fname = $_FILES['uploaded']['name'];<br />
 //Valid image extensions<br />
 $validext = array(&#8216;jpg&#8217;,'JPG&#8217;,'gif&#8217;,'GIF&#8217;,'bmp&#8217;,'BMP&#8217;,'tif&#8217;,'TIF&#8217;);<br />
 //Get the file extension<br />
 $fext = substr($_FILES['uploaded']['name'],-3);<br />
 //Check for a valid image file<br />
 if(!in_array($fext,$validext))<br />
  die(&#8216;Invalid File Type&#8217;);<br />
 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $imagesdir))<br />
  {<br />
  echo &#8220;Image file &#8220;. basename( $_FILES['uploaded']['name']). &#8221; uploaded successfully&#8221;;<br />
  }<br />
 else<br />
  {<br />
  echo &#8220;File not uploaded&#8221;;<br />
 }<br />
?&gt;</p>
<p>The above code checks that the file is a valid image file and uploads it if the extension is &#8220;gif&#8221;, &#8220;jpg&#8221;, &#8220;bmp&#8221;, or &#8220;tif&#8221;. Next I will display the uploaded images one at a time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=33&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/05/05/back-to-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding Found Files MySQL</title>
		<link>http://itc570af.wordpress.com/2010/04/03/adding-found-files-mysql/</link>
		<comments>http://itc570af.wordpress.com/2010/04/03/adding-found-files-mysql/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 05:34:28 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[HTML forms]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=28</guid>
		<description><![CDATA[Happy Easter to all. No rest though as I can see the light at the end of the tunnel. If I can just get this project completed and my other subject this semester, it should be smooth sailing in second semester with one subject left to complete my Master of IT. Anyway, on with today&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=28&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Happy Easter to all. No rest though as I can see the light at the end of the tunnel. If I can just get this project completed and my other subject this semester, it should be smooth sailing in second semester with one subject left to complete my Master of IT. Anyway, on with today&#8217;s project work.</p>
<p>In my work earlier this week I was able find files in a folder and subfolders and output their path to a DIV on the screen. Now I want to output those paths to the MySQL table &#8220;images&#8221; created earlier in the project. To do this, I created a MySQL login script called imageorguser.php with the code below:</p>
<p>&lt;?php<br />
$dbhost = &#8216;localhost&#8217;;<br />
$dbuser = &#8216;username&#8217;;<br />
$dbpass = &#8216;password&#8217;;</p>
<p>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (&#8216;Error connecting to mysql&#8217;);</p>
<p>$dbname = &#8216;imageorg&#8217;;<br />
mysql_select_db($dbname);<br />
?&gt;</p>
<p>I include these login details in findimages.php with the line of code below:</p>
<p>include(&#8220;imageorguser.php&#8221;);</p>
<p>2 new variables were added as below:</p>
<p> $importcounter = 0;<br />
 $importcount = 0;</p>
<p>importcounter is used at import time to advised the user onscreen how many images were imported. importcount is set in the table images as &#8220;1&#8243; for each image file imported. This will be used later to determine how many images still need to be processed by &#8220;summing&#8221; this field.</p>
<p>The line below was added to process the slashes correctly when inserting records into the database:</p>
<p>$newfilestr = addslashes($newfilestr);</p>
<p>Finally, the line below does the actual insert of the fields inputfile, importtime, and importcount:</p>
<p>mysql_query(&#8220;INSERT INTO images(inputfile, importtime, importcount)&#8221;.&#8221;VALUES(&#8216;$newfilestr&#8217;,'$importtime&#8217;,'$importcount&#8217;)&#8221;) or die(mysql_error());</p>
<p>The full code of findimages.php at its current state is shown below:</p>
<p>&lt;?php<br />
 include(&#8220;imageorguser.php&#8221;);<br />
 //Directory to start from<br />
 $userinput = $_POST["upload"];<br />
 $importcounter = 0;<br />
 $importcount = 0;<br />
 $startdir = new RecursiveDirectoryIterator(&#8220;$userinput&#8221;);<br />
 //Set Current Directory and find files<br />
 $curdir = new RecursiveIteratorIterator($startdir, RecursiveIteratorIterator::SELF_FIRST);<br />
 //set image file extensions that we want to search for<br />
 $imgextensions = array(&#8216;jpg&#8217;,'JPG&#8217;,'gif&#8217;,'GIF&#8217;,'png&#8217;,'PNG&#8217;,'bmp&#8217;,'BMP&#8217;);<br />
 foreach ($curdir as $file) {<br />
  //Replace backslashes in string with forward slashes to prevent PHP escape problems later<br />
      $newfilestr = str_replace(&#8216;\\&#8217;,'/&#8217;, $file);<br />
  //Get the file extension for the current file<br />
  $newfileext = substr($newfilestr, -3);<br />
  //If the current file is a file that we want<br />
  if (in_array($newfileext, $imgextensions)) {<br />
   $newfilestr = addslashes($newfilestr);<br />
       echo $newfilestr, &#8221; &#8220;;<br />
   $importtime = date(&#8216;Y-m-d H:m:s&#8217;);<br />
   echo $importtime, &#8221; &#8220;;<br />
   $importcount = 1;<br />
   $importcounter++;<br />
   echo $importcount, &#8220;&lt;BR&gt;&#8221;;<br />
   mysql_query(&#8220;INSERT INTO images(inputfile, importtime, importcount)&#8221;.&#8221;VALUES(&#8216;$newfilestr&#8217;,'$importtime&#8217;,'$importcount&#8217;)&#8221;) or die(mysql_error());<br />
  }<br />
 }<br />
 echo &#8220;Files imported: &#8220;, $importcounter;<br />
?&gt;</p>
<p>When I type &#8220;C:\temp&#8221; into the form on fileupload.html and click on submit, the following is the output of running the query select * from imageorg.images; in MySQL Query Browser.</p>
<p><a href="http://itc570af.files.wordpress.com/2010/04/wk5-1.jpg"><img class="alignleft size-full wp-image-29" title="wk5-1" src="http://itc570af.files.wordpress.com/2010/04/wk5-1.jpg?w=450&#038;h=324" alt="" width="450" height="324" /></a></p>
<p>As you can see, 17 rows were fetched, which is the same number that we got previously, and the file paths look correct, so the new code has worked as expected.</p>
<p>Next we will display the images one at a time in the web browser.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=28&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/04/03/adding-found-files-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/04/wk5-1.jpg" medium="image">
			<media:title type="html">wk5-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding JQuery and AJAX to Submit Form Data</title>
		<link>http://itc570af.wordpress.com/2010/03/31/adding-jquery-and-ajax-to-submit-form-data/</link>
		<comments>http://itc570af.wordpress.com/2010/03/31/adding-jquery-and-ajax-to-submit-form-data/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 06:40:59 +0000</pubDate>
		<dc:creator>just me</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Find Files]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://itc570af.wordpress.com/?p=23</guid>
		<description><![CDATA[I only recently discovered the magic of AJAX, and even more recently JQuery. AJAX makes a webpage intuitive, and applications in a web browser can behave like standalone applications. What I mean by this is that you can display and remove what you want, where you want, when you want without ever having to refresh [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=23&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I only recently discovered the magic of AJAX, and even more recently JQuery.</p>
<p>AJAX makes a webpage intuitive, and applications in a web browser can behave like standalone applications. What I mean by this is that you can display and remove what you want, where you want, when you want without ever having to refresh your browser.</p>
<p>When I first started looking at JQuery I thought that it could be useful for certain functionality. Now that I am actually using it in this project I am seeing the benefits of greatly reduced coding, as JQuery does the fiddly bits for me.</p>
<p>I start today by creating some JavaScript in the file submitimageform.js as below:</p>
<p>$(document).ready(function() {<br />
  $(function() {<br />
  $(&#8220;.submit&#8221;).click(function() {<br />
  var upload = $(&#8220;#upload&#8221;).val();<br />
  var dataString = &#8216;upload=&#8217;+ upload;</p>
<p>  if(upload==&#8221;)<br />
    {<br />
    $(&#8216;.success&#8217;).hide();<br />
    $(&#8216;.error&#8217;).show();<br />
    }<br />
  else<br />
    {<br />
    $.ajax({<br />
      type: &#8220;POST&#8221;,<br />
      url: &#8220;findimages.php&#8221;,<br />
      data: dataString,<br />
      success: function(html){<br />
      $(&#8220;#output&#8221;).append(html);<br />
      }<br />
    });<br />
  }<br />
  return false;<br />
  });<br />
  });<br />
});</p>
<p>Next I modified fileupload.html and added the following 2 lines to the HEAD section:</p>
<p>  &lt;script type=&#8221;text/javascript&#8221; src=&#8221;jquery.js&#8221;&gt;&lt;/script&gt;<br />
  &lt;script type=&#8221;text/javascript&#8221; language=&#8221;javascript&#8221; src=&#8221;submitimageform.js&#8221;&gt;&lt;/script&gt;</p>
<p>This runs the jquery.js script to make JQuery functionality available, and then runs submitimageforms.js to perform required functions when certain actions occur within the page. The specific function within JQuery that we are calling is .ajax with parameters of type, url, data, and success.</p>
<p>I also added the code below to the DIV with the ID &#8220;output&#8221; to tell the script where to display the output of the PHP script.</p>
<p>   &lt;span style=&#8221;display:none&#8221;&gt; Please Enter Valid Data&lt;/span&gt;<br />
   &lt;span style=&#8221;display:none&#8221;&gt;&lt;/span&gt;</p>
<p>As you can see below, the form output is now displayed below the form without refreshing the page.</p>
<p><a href="http://itc570af.files.wordpress.com/2010/03/wk4-11.jpg"><img class="alignleft size-full wp-image-25" title="wk4-1" src="http://itc570af.files.wordpress.com/2010/03/wk4-11.jpg?w=355&#038;h=560" alt="" width="355" height="560" /></a></p>
<p>The references below were used for hints and clues on specific functionality during the process of coding this section of the project:</p>
<p><strong>References</strong></p>
<p>&#8220;Load a Page Without Refreshing&#8221;, 12:46AM, 8th December 2008. Posting by &#8220;acctman&#8221; . Retrieved 31st March 2010 from <a href="http://www.dynamicdrive.com/forums/archive/index.php/t-35337.html">http://www.dynamicdrive.com/forums/archive/index.php/t-35337.html</a></p>
<p>Tamada, S. (2009). &#8220;Submit a Form Without Refreshing Page With JQuery and Ajax&#8221;. Retrieved 31st March 2010 from <a href="http://www.9lessons.info/2009/04/submit-form-jquery-and-ajax.html">http://www.9lessons.info/2009/04/submit-form-jquery-and-ajax.html</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/itc570af.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/itc570af.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/itc570af.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/itc570af.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/itc570af.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/itc570af.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/itc570af.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/itc570af.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=itc570af.wordpress.com&amp;blog=12323777&amp;post=23&amp;subd=itc570af&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://itc570af.wordpress.com/2010/03/31/adding-jquery-and-ajax-to-submit-form-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f290ae0fe0fdbe1804c093e638bcb088?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">just me</media:title>
		</media:content>

		<media:content url="http://itc570af.files.wordpress.com/2010/03/wk4-11.jpg" medium="image">
			<media:title type="html">wk4-1</media:title>
		</media:content>
	</item>
	</channel>
</rss>
