Joomla admin panel Image/file upload

Hi Friends,

This is the nice for the file upload in custom component at admin panel

At your controller file

Step 1

Add this three lines in header


Step 2

Inside save function add this below lines

$fieldName = ‘upload_file’;
if($_FILES[$fieldName][‘name’] != ”) {
$fileName = $_FILES[$fieldName][‘name’];
$fileTemp = $_FILES[$fieldName][‘tmp_name’];
//lose any special characters in the filename
$fileName = ereg_replace(“[^A-Za-z0-9.]”, “-“, $fileName);
$fileName = time().’_’.$fileName;

//always use constants when making file paths, to avoid the possibilty of remote file inclusion
$uploadPath = JPATH_SITE.DS.’images’.DS.’stories’.DS.$fileName;

if(!JFile::upload($fileTemp, $uploadPath)) {
echo JText::_( ‘ERROR MOVING FILE’ );
$data[‘image’] =  $fileName;


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: