Image and File upload

What do you use as a KTML Replacement.
Give the pros and cons of the application and where to find it.
User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

Image and File upload

Post by Fred » 2011-07-01 13:38

Like I said in a different post, I found an image and file up loader that can be integrated with tinymce as a replacement for KTML
Ajax File/Image Manager by phpletter

I had one issue and that was that the KTML uploader supports the dynamic creation of folders for different members.

A hack to allow the Ajax File / Image Manager do the same.
Things to consider.
  • 1. Different user needs different folders, dynamically created if it doesn't exist.
    2. Depending on what page the user is on, you might need different folders.
Locate config.base.php in the ajaxfilemanager/inc folder

First we need to find out what page we are on.

Code: Select all

// Check what page we are on
// My current code   
$req_uri = $_SESSION['page'];
$check = 'article_update.php';
$page = strpos($req_uri, $check);
Search for the following lines:

Code: Select all

	define('CONFIG_SYS_DEFAULT_PATH', '../uploaded/'); //accept relative path only
	define('CONFIG_SYS_ROOT_PATH', '../uploaded/');	//accept relative path only
and replace with

Code: Select all

if ($page !== false) { // Set default upload settings for the articles in member section
   // Check if folder exists
   if (!is_dir('../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'')) {
   mkdir('../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'', 0755); // Create the folder and set permissions
   }
   // Continue setting the default folders
   define('CONFIG_SYS_DEFAULT_PATH', '../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'/'); //accept relative path only
   define('CONFIG_SYS_ROOT_PATH', '../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'/');   //accept relative path only
}   else { // Use default settings if not members article pages
   define('CONFIG_SYS_DEFAULT_PATH', '../../../../uploads/media/'); //accept relative path only
   define('CONFIG_SYS_ROOT_PATH', '../../../../uploads/media/');   //accept relative path only
}
So your complete code that you need to insert / replace looks like this

Code: Select all

// Check what page we are on      
$req_uri = $_SESSION['page'];
$check = 'article_update.php';
$page = strpos($req_uri, $check);

if ($page !== false) { // Set default upload settings for the articles in member section
   // Check if folder exists and create
   if (!is_dir('../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'')) {
   mkdir('../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'', 0755); // Create the folder and set permissions
   }
   // Continue setting the default folders
   define('CONFIG_SYS_DEFAULT_PATH', '../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'/'); //accept relative path only
   define('CONFIG_SYS_ROOT_PATH', '../../../../uploads/media/Members/'.$_SESSION['kt_login_id'].'/');   //accept relative path only
}   else { // Use default settings if not members article pages
   define('CONFIG_SYS_DEFAULT_PATH', '../../../../uploads/media/'); //accept relative path only
   define('CONFIG_SYS_ROOT_PATH', '../../../../uploads/media/');   //accept relative path only
}
Obviously adjust the folders and variables to suit your needs.