<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dominik</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dominik"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Dominik"/>
	<updated>2026-08-20T03:19:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5_talk:Using_JPagination_in_your_component&amp;diff=28258</id>
		<title>J1.5 talk:Using JPagination in your component</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5_talk:Using_JPagination_in_your_component&amp;diff=28258"/>
		<updated>2010-05-29T18:37:02Z</updated>

		<summary type="html">&lt;p&gt;Dominik: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This code does not work correctly as it stores the limitstart into a session variable.  &lt;br /&gt;
So, when clicking upon the first item in your pages list, no limitstart variable is present and so the previously saved limitstart value is reused.&lt;br /&gt;
&lt;br /&gt;
ie. you can go to pages 2, 3, etc. but not back down to 1.&lt;br /&gt;
&lt;br /&gt;
A work around I have used is to always get the value from the Request object.&lt;br /&gt;
&lt;br /&gt;
//$limitstart = $mainframe-&amp;gt;getUserStateFromRequest($option.&#039;.limitstart&#039;, &#039;limitstart&#039;, 0, &#039;int&#039;);&lt;br /&gt;
&lt;br /&gt;
$limitstart = JRequest::getVar(&#039;limitstart&#039;,0);&lt;br /&gt;
&lt;br /&gt;
Confirmed and fixed.  Thanks.  [[User:Chris Davenport|Chris Davenport]] 23:03, 31 May 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
I have one question&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The example changes to the model seem to call the query twice, once with and once without the LIMIT. Should this not use the same SQL_CALC_FOUND_ROWS method mentioned in the &amp;quot;Examples with JDatabase&amp;quot; section? [[User:Crispy|Crispy]] 11:49, 28 October 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
Yes.  Please go ahead and change it. [[User:Chris Davenport|Chris Davenport]] 18:39, 28 October 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using SQL_CALC_FOUND_ROWS is not necessarily better, particularly for indexed queries: &amp;lt;i&amp;gt;[http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/ To SQL_CALC_FOUND_ROWS or not to SQL_CALC_FOUND_ROWS?]&amp;lt;/i&amp;gt;. [[User:Tenorviol|Chris Johnson]] 23:08, 30 October 2009&lt;br /&gt;
&lt;br /&gt;
Besides the questionable efficiency impact, the listed implementation of the SQL_CALC_FOUND_ROWS suffers from a race condition that may cause concurrent pagination requests to get inaccurate counts by resetting FOUND_ROWS()&#039;s data before it can be checked in the subsequent request. Combining the queries something like SELECT SQL_CALC_ROWS NULL AS count, x, y, z FROM xyz LIMIT a, b UNION SELECT FOUND_ROWS() AS count, NULL AS x, NULL AS y, NULL AS z ORDER BY CASE WHEN count IS NULL THEN 1 ELSE 0 END then dealing with the special case first row in PHP probably makes it atomic, but I have to wonder if it&#039;s really worth the added complexity. [[User:Ralph|Ralph]] 02:22, 29 January 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is no solution given for the problem with two different views in one component that use pagination. [[User:Dominik|Dominik]] 18:37, 29 May 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Dominik</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=How_to_use_the_filesystem_package&amp;diff=28139</id>
		<title>How to use the filesystem package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=How_to_use_the_filesystem_package&amp;diff=28139"/>
		<updated>2010-05-27T12:02:03Z</updated>

		<summary type="html">&lt;p&gt;Dominik: pre-&amp;gt;source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Using the JFILE:: class=&lt;br /&gt;
&lt;br /&gt;
There are 4 classes in the J15 filesystem library.&lt;br /&gt;
&lt;br /&gt;
* JFile:: (file.php)&lt;br /&gt;
* JFolder:: (folder.php)&lt;br /&gt;
* JPath:: (path.php)&lt;br /&gt;
* JArchive:: (archive.php)[/i]&lt;br /&gt;
&lt;br /&gt;
For this first tutorial, I will focus on the JFile:: class.&lt;br /&gt;
&lt;br /&gt;
The base for filehandling is the JFile class, found in libraries/joomla/filesystem/file.php&lt;br /&gt;
Below I will discuss the most common options from this library file. At the end of this post, I put it together in a very simple script for file upload.&lt;br /&gt;
&lt;br /&gt;
==Get file extension==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$ext =  JFile::getExt($filename);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pretty clear, just feed the function with a filename and it will return the extension of the file you selected.&lt;br /&gt;
&lt;br /&gt;
==Strip file extension==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$name = JFile::stripExt($filename);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will return the filename without the extension.&lt;br /&gt;
&lt;br /&gt;
==Clean filename==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$safefilename = JFile::makeSafe($filename);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It cleans out all odd characters from a filename and returns a safe filename.&lt;br /&gt;
&lt;br /&gt;
==Copy a file==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFile::copy($src, $dest);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is basically a wrapper for the PHP copy() function, but also checks if the file you want to copy exists and the destination really is available. Great thing is that this function also makes use of the FTP-layer in J15 if necessary.&lt;br /&gt;
&lt;br /&gt;
==Delete a file==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFile::delete($path.$file);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It tries to delete the file, making sure it is actually existing, but also checks permissions. If permissions are not set up properly, it tries to change them and delete the file. It also uses the FTP-layer when necessary.&lt;br /&gt;
&lt;br /&gt;
==Upload a file==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFile::upload($src, $dest);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is basically the wrapper for the PHP move_uploaded_file() function, but also does checks availability and permissions on both source and destination path.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
So how does that look in a script? I put up a small code snippet of an upload script. Some of the functions are used.&lt;br /&gt;
The script is fired from an upload form. That form has a file element, called file_upload (see below).&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;form name=&amp;quot;upload&amp;quot; method=&amp;quot;post&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;file&amp;quot; name=&amp;quot;file_upload&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upload code looks like this:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
***********************&lt;br /&gt;
*                     *&lt;br /&gt;
* File upload example *&lt;br /&gt;
*                     *&lt;br /&gt;
***********************&lt;br /&gt;
//Retrieve file details from uploaded file, sent from upload form&lt;br /&gt;
$file = JRequest::getVar(&#039;file_upload&#039;, null, &#039;files&#039;, &#039;array&#039;);&lt;br /&gt;
&lt;br /&gt;
//Import filesystem libraries. Perhaps not necessary, but does not hurt&lt;br /&gt;
jimport(&#039;joomla.filesystem.file&#039;);&lt;br /&gt;
&lt;br /&gt;
//Clean up filename to get rid of strange characters like spaces etc&lt;br /&gt;
$filename = JFile::makeSafe($file[&#039;name&#039;]);&lt;br /&gt;
&lt;br /&gt;
//Set up the source and destination of the file&lt;br /&gt;
$src = $file[&#039;tmp_name&#039;];&lt;br /&gt;
$dest = JPATH_COMPONENT . DS . &amp;quot;uploads&amp;quot; . DS . $filename;&lt;br /&gt;
&lt;br /&gt;
//First check if the file has the right extension, we need jpg only&lt;br /&gt;
if ( strtolower(JFile::getExt($filename) ) == &#039;jpg&#039;) {&lt;br /&gt;
   if ( JFile::upload($src, $dest) ) {&lt;br /&gt;
      //Redirect to a page of your choice&lt;br /&gt;
   } else {&lt;br /&gt;
      //Redirect and throw an error message&lt;br /&gt;
   }&lt;br /&gt;
} else {&lt;br /&gt;
   //Redirect and notify user file is not right extension&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Upload - Full Sample=&lt;br /&gt;
&lt;br /&gt;
Little sample where admin choose the file type or all, enter the users to access the form upload.&lt;br /&gt;
Folder to upload files in Joomla directory or with absolute path.&lt;br /&gt;
Only selected users access the form upload.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mod_simpleupload.xml&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;install type=&amp;quot;module&amp;quot; version=&amp;quot;1.5.0&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;name&amp;gt;Simple Upload 1.3&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;Ribamar FS&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;fevereiro 2010&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;(C) 2005 Open Source Matters. All rights reserved.&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;http://www.gnu.org/copyleft/gpl.html GNU/GPL&amp;lt;/license&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;ribafs@gmail.com&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;http://ribafs.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.3&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Simple Upload 1.3 - Simple upload with Joomla Framework.&amp;lt;/description&amp;gt;&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_simpleupload&amp;quot;&amp;gt;mod_simpleupload.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;params&amp;gt;&lt;br /&gt;
		&amp;lt;param name=&amp;quot;dir&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Directory&amp;quot; description=&amp;quot;Directory Upload&amp;quot; default=&amp;quot;upload&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;param name=&amp;quot;type&amp;quot; type=&amp;quot;list&amp;quot; default=&amp;quot;*&amp;quot; label=&amp;quot;Select a file type&amp;quot; description=&amp;quot;File type&amp;quot;&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;*&amp;quot;&amp;gt;Any File &amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;image/png&amp;quot;&amp;gt;PNG&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;image/gif&amp;quot;&amp;gt;GIF&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;image/jpeg&amp;quot;&amp;gt;JPEG&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;application/zip&amp;quot;&amp;gt;ZIP&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;application/x-gzip&amp;quot;&amp;gt;TAR.GZ&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;text/html&amp;quot;&amp;gt;HTML&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;text/plain&amp;quot;&amp;gt;TXT&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;application/pdf&amp;quot;&amp;gt;PDF&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;option value=&amp;quot;application/msword&amp;quot;&amp;gt;DOC&amp;lt;/option&amp;gt;&lt;br /&gt;
           &amp;lt;/param&amp;gt;          &lt;br /&gt;
		&amp;lt;param name=&amp;quot;user_names&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;User Names (optional)&amp;quot; description=&amp;quot;Names users (optionas)&amp;quot; default=&amp;quot;&amp;quot;/&amp;gt;    &lt;br /&gt;
	&amp;lt;/params&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
mod_simpleupload.php&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// no direct access&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
//Import filesystem libraries. Perhaps not necessary, but does not hurt&lt;br /&gt;
jimport(&#039;joomla.filesystem.file&#039;);&lt;br /&gt;
&lt;br /&gt;
$max = ini_get(&#039;upload_max_filesize&#039;);&lt;br /&gt;
$module_dir = $params-&amp;gt;get( &#039;dir&#039; );&lt;br /&gt;
$file_type = $params-&amp;gt;get( &#039;type&#039; );&lt;br /&gt;
&lt;br /&gt;
$user_names = $params-&amp;gt;get( &#039;user_names&#039; );&lt;br /&gt;
$msg = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
function fileUpload($max, $module_dir, $file_type, $msg){&lt;br /&gt;
	//Retrieve file details from uploaded file, sent from upload form&lt;br /&gt;
	$file = JRequest::getVar(&#039;file_upload&#039;, null, &#039;files&#039;, &#039;array&#039;); &lt;br /&gt;
	// Retorna: Array ( [name] =&amp;gt; mod_simpleupload_1.2.1.zip [type] =&amp;gt; application/zip &lt;br /&gt;
	// [tmp_name] =&amp;gt; /tmp/phpo3VG9F [error] =&amp;gt; 0 [size] =&amp;gt; 4463 ) &lt;br /&gt;
&lt;br /&gt;
	if(isset($file)){ &lt;br /&gt;
		//Clean up filename to get rid of strange characters like spaces etc&lt;br /&gt;
		$filename = JFile::makeSafe($file[&#039;name&#039;]);&lt;br /&gt;
&lt;br /&gt;
		if($file[&#039;size&#039;] &amp;gt; $max) $msg = JText::_(&#039;ONLY_FILES_UNDER&#039;).&#039; &#039;.$max;&lt;br /&gt;
		//Set up the source and destination of the file&lt;br /&gt;
&lt;br /&gt;
		$src = $file[&#039;tmp_name&#039;];&lt;br /&gt;
		$dest = $module_dir . DS . $filename;&lt;br /&gt;
&lt;br /&gt;
		//First check if the file has the right extension, we need jpg only&lt;br /&gt;
		if ($file[&#039;type&#039;] == $file_type || $file_type == &#039;*&#039;) { &lt;br /&gt;
		   if ( JFile::upload($src, $dest) ) {&lt;br /&gt;
&lt;br /&gt;
  		       //Redirect to a page of your choice&lt;br /&gt;
			$msg = JText::_(&#039;FILE_SAVE_AS&#039;).&#039; &#039;.$dest;&lt;br /&gt;
		   } else {&lt;br /&gt;
			  //Redirect and throw an error message&lt;br /&gt;
			$msg = JText::_(&#039;ERROR_IN_UPLOAD&#039;);&lt;br /&gt;
		   }&lt;br /&gt;
		} else {&lt;br /&gt;
		   //Redirect and notify user file is not right extension&lt;br /&gt;
			$msg = JText::_(&#039;FILE_TYPE_INVALID&#039;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$msg = &amp;quot;&amp;lt;script&amp;gt;alert(&#039;&amp;quot;. $msg .&amp;quot;&#039;);&amp;lt;/script&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	return $msg;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$user =&amp;amp; JFactory::getUser();&lt;br /&gt;
$username = $user-&amp;gt;get(&#039;username&#039;);&lt;br /&gt;
&lt;br /&gt;
$acc = 0;&lt;br /&gt;
$session =&amp;amp; JFactory::getSession(); &lt;br /&gt;
&lt;br /&gt;
if(isset($user_names)) {&lt;br /&gt;
	$more = strpos($user_names, &#039;,&#039;,0);&lt;br /&gt;
	if($more &amp;gt;0){&lt;br /&gt;
		$user_names = explode(&#039;,&#039;,$user_names);&lt;br /&gt;
		foreach($user_names as $un){&lt;br /&gt;
			if($un == $username) {&lt;br /&gt;
				$session-&amp;gt;set($acc, 1); &lt;br /&gt;
			}else{&lt;br /&gt;
				$session-&amp;gt;set($acc, 0); &lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}else{&lt;br /&gt;
		if ($user_names == $username) $session-&amp;gt;set($acc, 1); &lt;br /&gt;
	}&lt;br /&gt;
}else{&lt;br /&gt;
	if(isset($username)) $session-&amp;gt;set($acc, 1); &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if($session-&amp;gt;get($acc) == 1){&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;form name=&amp;quot;imgform&amp;quot; method=&amp;quot;post&amp;quot; action=&amp;quot;&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot; onSubmit=&amp;quot;if(file_upload.value==&#039;&#039;) {alert(&#039;Choose a file!&#039;);return false;}&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php echo JText::_(&#039;CHOOSE_FILE&#039;); ?&amp;gt; &amp;lt;input type=&amp;quot;file&amp;quot; name=&amp;quot;file_upload&amp;quot; size=&amp;quot;10&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;input name=&amp;quot;submit&amp;quot; type=&amp;quot;submit&amp;quot; value=&amp;quot;Upload&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	print fileUpload($max, $module_dir, $file_type, $msg);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Adapted from http://docs.joomla.org/How_to_use_the_filesystem_package&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Using the JFolder:: class=&lt;br /&gt;
The base for folder handling is the JFolder class, found in libraries/joomla/filesystem/folder.php&lt;br /&gt;
Below I will discuss the most common options from this library file. At the end of this post, I put it together in a very simple script as an exmaple&lt;br /&gt;
&lt;br /&gt;
==Copy folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::copy($src, $dest, $path, $force);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will copy a complete folder and all of it’s contents to another location on the server. It does permission and availability checking on both source and destination. By using $path you can enter a basepath to prefix to the filename and by setting the $force parameter to true, you can force the overwriting of already existing files. If set in the configuration, the FTP-layer will be used.&lt;br /&gt;
&lt;br /&gt;
==Create folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::create($path, $mode);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is basically a wrapper for the php mkdir() function, but with error permissions and availability checking. This one also uses the FTP-layer when set in the configuration. $mode will set the default permission, once copied and defaults to 0755.&lt;br /&gt;
&lt;br /&gt;
==Move folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::move($src, $dest);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Basically a wrapper for the php rename() function, but with permissions and availability checking. This one also uses the FTP-layer when set in the configuration.&lt;br /&gt;
&lt;br /&gt;
==Check if folder exists==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::exists($path);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Wrapper for the php is_dir() function. Pretty straightforward, returns true if folder exists.&lt;br /&gt;
&lt;br /&gt;
==Read files from folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::files($path, $filter = &#039;.&#039;, $recurse, $fullpath , $exclude);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Function to read files from a folder. When setting $recurse to true, also subfolders will be searched. $fullpath set to true returns the full path in the array. With $exclude, you can offer an array of extensions, not to include in the search for files. It returns an array with all filenames.&lt;br /&gt;
&lt;br /&gt;
==Read folders from filesystem==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::folders($path, $filter = &#039;.&#039;, $recurse, $fullpath , $exclude);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Exactly the same as JFolder::files(), except this does only return an array with foldernames.&lt;br /&gt;
&lt;br /&gt;
==Make a tree like list from a folder structure==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It will read a folder, specified in $path and will return all folders in an array, suitable for tree display. You can specify the number of levels. The folder array looks like this:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
    [0] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [id] =&amp;gt; 1&lt;br /&gt;
            [parent] =&amp;gt; 0&lt;br /&gt;
            [name] =&amp;gt; administrator&lt;br /&gt;
            [fullname] =&amp;gt; g:/joomla_1012/administrator&lt;br /&gt;
            [relname] =&amp;gt; g:/joomla_1012/administrator&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
    [1] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [id] =&amp;gt; 2&lt;br /&gt;
            [parent] =&amp;gt; 1&lt;br /&gt;
            [name] =&amp;gt; backups&lt;br /&gt;
            [fullname] =&amp;gt; g:/joomla_1012/administrator/backups&lt;br /&gt;
            [relname] =&amp;gt; g:/joomla_1012/administrator/backups&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
    [2] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [id] =&amp;gt; 3&lt;br /&gt;
            [parent] =&amp;gt; 1&lt;br /&gt;
            [name] =&amp;gt; components&lt;br /&gt;
            [fullname] =&amp;gt; g:/joomla_1012/administrator/components&lt;br /&gt;
            [relname] =&amp;gt; g:/joomla_1012/administrator/components&lt;br /&gt;
        )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Clean a path string==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::makeSafe($path);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Identically to the JFile::makeSafe() function. It cleans all odd characters out of the string and returns a clean path.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Ok, and how does this look in actual code. We are going to read the contents of a folder called images. In it, al large number of files are placed. We want to create a subfolder, called jpg and filter all jpg files out and move them to the jpg subfolder. After that, we will move the complete subfolder to another place on the server.&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//First we set up parameters&lt;br /&gt;
$searchpath = JPATH_COMPONENT . DS . &amp;quot;images&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
//Then we create the subfolder called jpg&lt;br /&gt;
if ( !JFolder::create($searchpath . DS . &amp;quot;jpg&amp;quot;) ) {&lt;br /&gt;
   //Throw error message and stop script&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Now we read all jpg files and put them in an array.&lt;br /&gt;
$jpg_files = JFolder::files($searchpath, &#039;.jpg&#039;);&lt;br /&gt;
&lt;br /&gt;
//Now we need some stuff from the JFile:: class to move all files into the new folder&lt;br /&gt;
foreach ($jpg_files as $file) {&lt;br /&gt;
   JFile::move($searchpath. DS . $file, $searchpath . DS. &amp;quot;jpg&amp;quot; . $file);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Lastly, we are moving the complete subdir to the root of the component.&lt;br /&gt;
if (JFolder::move($searchpath . DS. &amp;quot;jpg&amp;quot;, $JPATH_COMPONENT) ) {&lt;br /&gt;
   //Redirect with perhaps a happy message&lt;br /&gt;
} else {&lt;br /&gt;
   //Throw an error&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example script only, but gives a general idea of the possibilities. I did not touch other stuff like JError to keep it clean and simple.&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Development]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dominik</name></author>
	</entry>
</feed>