Saturday 5 October 2013

file upload with ajaxPost title


/*
+------------------------------------------------------------------+
Function will be use for ajax uploading image.
@params-> $module : Name of module name for upload image
$fileType : Name of file type
$inputFile : Input file name
$watermark = false : if not watermark image
+------------------------------------------------------------------+
*/
function ajaxUploading($module, $fileType, $inputFile, $watermark=false)
{
//print_r($_FILES);die;
if($_FILES[$inputFile]["name"])
$new_file_name = alterFileName($_FILES[$inputFile]["name"]);
else
$new_file_name = '';

$data['type'] = $_FILES[$inputFile]["type"];
$folder = 'uploads/'.$module;
if(!file_exists($folder))
{
mkdir($folder,0777,true);
chmod($folder,0777);
}

$res = $this->mdl_common->uploadFile($inputFile, $fileType, $folder, $watermark, $new_file_name);

if($res['success'])
{
if($this->router->class == 'brochures')
{
$actual_image = $res["path"];
$thumb_path = load_thumb_image_nmd($actual_image);
resize_image($actual_image,$thumb_path,600,440);
}

$data['link'] = $res["path"];
$data['input'] = $inputFile;
return $this->load->view('admin/elements/ajax_view_image',$data,true);
}
else
{
$res['error'] = strip_tags($res['error']);
return $res;
}
}

No comments:

Post a Comment