/**
  * Uploadify上传文件处理
  */
 public function hd_uploadify()
 {
     $uploadModel = M('upload');
     $size = Q('size') ? Q('size') : C('allow_size');
     $upload = new Upload(Q('post.upload_dir'), array(), $size);
     $file = $upload->upload();
     if (!empty($file)) {
         $file = $file[0];
         $file['uid'] = session('uid');
         //图片加水印
         if ($file['image'] && Q('water')) {
             $img = new Image();
             $img->water($file['path']);
         }
         //写入upload表
         $uploadModel->add($file);
         $data = $file;
         $data['status'] = 1;
         $data['isimage'] = $file['image'] ? 1 : 0;
     } else {
         $data['status'] = 0;
         $data['message'] = $upload->error;
     }
     echo json_encode($data);
     exit;
 }
 public function addHander()
 {
     // p($_FILES);
     // p($_POST);
     preg_match_all('/<\\s*img\\s+[^>]*?src\\s*=\\s*(\'|\\")(.*?)\\">/i', $_POST['details'], $result, PREG_SET_ORDER);
     $dir = MYPHP_TEMP_PATH . "/Article/" . $_POST['column_id'] . '/' . $_POST['category_id'];
     is_dir($dir) || mkdir($dir, 0777, true);
     chmod($dir, 0777);
     $aid = (int) file_get_contents(MYPHP_TEMP_PATH . '/Dbid/Article/Article/dbid.txt');
     $fileName = $dir . '/' . date('Y-m-d') . '-' . $_POST['column_id'] . '-' . $_POST['category_id'] . '-' . ($aid + 1) . '.txt';
     $data = array();
     foreach ($result as $v) {
         $data[] = $v[0];
     }
     // p($fileName);die;
     file_put_contents($fileName, serialize($data));
     $details = preg_replace('/<\\s*img\\s+[^>]*?src\\s*=\\s*(\'|\\")(.*?)\\">/i', "<baseImg/>", $_POST['details']);
     if (isset($_FILES['thumb'])) {
         $upload = new Upload('Upload/Article/images/' . date("Y/m/d"));
         $files = $upload->upload();
     }
     // p($files);
     // die;
     $articleData = array('column_id' => $_POST['column_id'], 'category_id' => $_POST['category_id'], 'title' => $_POST['title'], 'tags' => $_POST['tags'], 'recommend' => $_POST['recommend'], 'author' => isset($_POST['author']) ? $_POST['author'] : $_SESSION['uname'], 'source' => $_POST['source'], 'details' => $_POST['details'], 'display' => $_POST['display'], 'thumb' => empty($files[0]['path']) ? "" : $files[0]['path'], 'image' => $fileName, 'create_time' => time());
     $articleData['details'] = $details;
     if (K('Article')->addArticle($articleData)) {
         $this->success('文章添加成功', __APP__ . '?c=Article&a=listArticle');
     } else {
         $this->error('文章添加失败');
     }
 }
Beispiel #3
0
 public function addUser()
 {
     if (IS_POST) {
         //上传头像的路径
         $path = 'Upload/UserImages/' . date("Y/m/d");
         $data = $_POST;
         $data['password'] = md5($data['password']);
         $data['create_time'] = time();
         $user = K('User');
         if (!$user->valid($data['username'])) {
             if (isset($_FILES['user_img'])) {
                 $upload = new Upload($path);
                 $files = $upload->upload();
             }
             $data['user_img'] = $files[0]['path'];
             if ($user->addUser($data)) {
                 $this->success('用户添加成功!', U('listUser', array('p' => 1)));
             } else {
                 $this->error('用户添加失败了,请检查填写信息!', U('addUser'));
             }
         } else {
             $this->error('用户添加失败,请检查填写信息!', U('addUser'));
         }
     }
     $this->display();
 }
Beispiel #4
0
 public function profileActAction()
 {
     $m['realname'] = $this->getPost('realname');
     $m['provinceID'] = $this->getPost('areaProvince');
     $m['cityID'] = $this->getPost('areaCity');
     $m['regionID'] = $this->getPost('areaRegion');
     $m['province'] = $this->load('Province')->getProvinceNameByID($m['provinceID']);
     $m['city'] = $this->load('City')->getCityNameByID($m['cityID']);
     if ($m['regionID']) {
         $m['region'] = $this->load('Region')->getRegionNameByID($m['regionID']);
     }
     $code = $this->m_user->UpdateByID($m, USER_ID);
     // Upload avatar if selected
     if ($_FILES['avatar']['name']) {
         $fileName = CUR_TIMESTAMP;
         $up = new Upload($_FILES['avatar'], UPLOAD_PATH . '/');
         $result = $up->upload($fileName);
         if ($result == 1) {
             $m['avatar'] = $fileName . '.' . $up->extension;
             $this->m_user->UpdateByID($m, USER_ID);
         } else {
             jsAlert($result);
         }
     }
     if (FALSE === $code && $result != 1) {
         jsAlert('编辑个人信息失败, 请重试');
     }
     $this->redirect('/user/profile/edit');
 }
 /**
  * Uploadify上传文件处理
  */
 public function hd_uploadify()
 {
     $uploadModel = M('upload');
     //上传文件类型
     if (isset($_POST['type'])) {
         $type = str_replace('*.', '', $_POST['type']);
         $type = explode(';', $type);
     } else {
         $type = array();
     }
     $size = Q('size') ? Q('size') : C('allow_size');
     $upload = new Upload(Q('upload_dir'), $type, $size);
     $file = $upload->upload();
     if (!empty($file)) {
         $file = $file[0];
         $file['uid'] = $_SESSION['user']['uid'];
         //图片加水印
         if ($file['image'] && Q('water')) {
             $img = new Image();
             $img->water($file['path']);
         }
         //写入upload表
         $uploadModel->add($file);
         $data = $file;
         $data['status'] = 1;
     } else {
         $data['status'] = 0;
         $data['message'] = $upload->error;
     }
     echo json_encode($data);
     exit;
 }
Beispiel #6
0
 /**
  * Uploadify上传文件处理
  */
 public function hd_uploadify()
 {
     $uploadModel = M('upload');
     //开启裁切
     C('UPLOAD_IMG_RESIZE_ON', true);
     C('upload_img_max_width', $_POST['upload_img_max_width']);
     C('upload_img_max_height', $_POST['upload_img_max_height']);
     $upload = new Upload(Q('post.upload_dir'), array(), array(), Q("water", null, "intval"));
     $file = $upload->upload();
     if (!empty($file)) {
         $file = $file[0];
         $file['uid'] = session('uid');
         $data['stat'] = 1;
         $data['url'] = __ROOT__ . '/' . $file['path'];
         $data['path'] = $file['path'];
         $data['filename'] = $file['filename'];
         $data['name'] = $file['name'];
         $data['basename'] = $file['basename'];
         $data['thumb'] = array();
         $data['isimage'] = $file['image'];
         //写入upload表
         $uploadModel->add($file);
     } else {
         $data['stat'] = 0;
         $data['msg'] = $upload->error;
     }
     echo json_encode($data);
     exit;
 }
 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             /* 记录文件信息 */
             $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
             //在模板里的url路径
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             }
             // else {
             //     //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
             //     unset($info[$key]);
             // }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
Beispiel #8
0
 public function testExtension()
 {
     $this->instance->init();
     $this->instance->serverHandler =& $this->serverHandler;
     $this->serverHandler->expects($this->once())->method('name')->willReturn('tests/samsonos.png');
     $upload = new Upload(array('xls', 'gif'), null, $this->instance);
     $this->assertFalse($upload->upload());
 }
 /**
  * 图片上传类
  */
 public function upload()
 {
     $upload = new Upload('./Uploads/Logo/');
     $file = $upload->upload();
     if (empty($file)) {
         //相当于 echo json_code('上传失败');exit;
         $this->ajax('上传失败');
     } else {
         $data = $file[0];
         $this->ajax($data);
     }
 }
 /**
  * 上传栏目图片
  */
 public function categoryImage()
 {
     $upload = new Upload('Upload/Category');
     $file = $upload->upload();
     if (empty($file)) {
         $this->ajax('上传失败');
     } else {
         $data = $file[0];
         $data['uid'] = $_SESSION['user']['uid'];
         M('upload')->add($data);
         $this->ajax($data);
     }
 }
 public function edit()
 {
     if (IS_POST) {
         $upload = new Upload();
         $path = $upload->upload('logo');
         if ($path) {
             $_POST['logo'] = __ROOT__ . '/' . $path[0]['path'];
         }
         if ($this->db->save()) {
             $this->success('修改成功!', 'index');
         }
     } else {
         $nid = Q('id', 0, 'intval');
         $this->assign('field', $this->db->find($nid));
         $this->display();
     }
 }
Beispiel #12
0
 /**
  * 设置友情链接配置
  */
 public function set_config()
 {
     if ($this->create()) {
         //设置Logo
         if (!empty($_FILES['logo'])) {
             $upload = new Upload('upload/link/');
             if ($file = $upload->upload()) {
                 //新logo文件名
                 $new_logo = $file[0]['dir'] . 'logo' . '.' . $file[0]['ext'];
                 //改名
                 rename($file[0]['path'], $new_logo);
                 $this->data['logo'] = $new_logo;
             }
         }
         return $this->where('id=1')->update();
     }
 }
Beispiel #13
0
 /**
  * 修改链接
  * @return mixed
  */
 public function edit_link()
 {
     if ($this->create()) {
         //设置Logo
         if (!empty($_FILES['logo'])) {
             $upload = new Upload('upload/link/');
             if ($file = $upload->upload()) {
                 $this->data['logo'] = $file[0]['path'];
                 //删除原logo文件
                 $logo = $this->where('id=' . Q('id'))->getField('logo');
                 if (is_file($logo)) {
                     unlink($logo);
                 }
             }
         }
         return $this->save();
     }
 }
 public function addTemplate()
 {
     if (IS_POST) {
         $data = $_POST;
         $data['create_time'] = time();
         $path = 'Upload/TemplateImages/';
         if (isset($_FILES['thumb'])) {
             $upload = new Upload($path);
             $files = $upload->upload();
         }
         $data['thumb'] = $files[0]['path'];
         if (K('Template')->addTemplate($data)) {
             $this->success('模板风格添加成功添加成功!', U('template'));
         } else {
             $this->error('模板风格添加失败了,请检查填写信息!', U('addTemplate'));
         }
         // p($data);die;
     }
     $this->display();
 }
Beispiel #15
0
 public function edit_article()
 {
     if ($this->create()) {
         /**
          * 修改内容图片 
          * 如果$_FILES['thumb']['name']为空,没上传图(还用旧的)
          */
         //如果有上传的图片数据时才进行缩略图上传处理
         if (!empty($_FILES['thumb']['name'])) {
             //文章缩略图上传处理
             $upload = new Upload('upload/article/' . date("Y/m/d"));
             $file = $upload->upload();
             $this->data['thumb'] = $file[0]['path'];
             //删除旧的缩略图
             $thumb = $this->where("id=" . Q("id"))->getField('thumb');
             is_file($thumb) and unlink($thumb);
         }
         return $this->save();
     }
 }
Beispiel #16
0
<?php

$file = $_FILES['file_upload'];
$directory = mysqli_real_escape_string(db_connect(), $_POST['directory']);
if (substr($directory, -1) != '/') {
    $directory = '' . $directory . '/';
}
$upload = new Upload();
$upload->upload($file, $directory);
Beispiel #17
0
 /**
  * Yükleme işlemini gerçekleştirir
  *
  *  @return ImageCapsule|bool
  */
 public function upload()
 {
     $upload = parent::upload();
     if ($upload) {
         $upload = ['filepath' => $upload, 'name' => $this->getNewName(), 'target' => $this->getTarget(), 'ext' => $this->getExt(), 'size' => $this->getFile()['size']];
         return new ImageCapsule($upload);
     } else {
         return false;
     }
 }
Beispiel #18
0
// .-----------------------------------------------------------------------------------
// |  Software: [HDPHP framework]
// |   Version: 2013.01
// |      Site: http://www.hdphp.com
// |-----------------------------------------------------------------------------------
// |    Author: 向军 <*****@*****.**>
// | Copyright (c) 2012-2013, http://houdunwang.com. All Rights Reserved.
// |-----------------------------------------------------------------------------------
// |   License: http://www.apache.org/licenses/LICENSE-2.0
// '-----------------------------------------------------------------------------------
header("Content-Type: text/html; charset=utf-8");
C("debug", 0);
C("WATER_ON", intval($_GET['water']));
if ($_GET['maximagewidth'] != 'false' || $_GET['maximageheight'] != 'false') {
    $maximageheight = intval($_GET['maximageheight']);
    $maximagewidth = intval($_GET['maximagewidth']);
    $maximagewidth = $maximagewidth ? $maximagewidth : C("UPLOAD_IMG_MAX_WIDTH");
    $maximageheight = $maximageheight ? $maximageheight : C("UPLOAD_IMG_MAX_HEIGHT");
    C("UPLOAD_IMG_RESIZE_ON", true);
    C("UPLOAD_IMG_MAX_WIDTH", $maximagewidth);
    C("UPLOAD_IMG_MAX_HEIGHT", $maximageheight);
}
$upload = new Upload(C('EDITOR_SAVE_PATH'), '', intval($_GET['uploadsize']));
$file = $upload->upload();
if (!$file) {
    echo json_encode(array('error' => 1, 'message' => $upload->error));
    exit;
}
$file_url = __ROOT__ . '/' . $file[0]['path'];
echo json_encode(array('error' => 0, 'url' => $file_url));
exit;
Beispiel #19
0
			$e= new pExploit();
			$e->autor('anonymous');
			$e->title($vars->catname());
			$e->category($vars->category());
			$e->platform($vars->platform());
			$e->content($vars->content());
			$e->codeLanguage($vars->language());
			$verified=false;
			if ($vars->verified()=='on')
			$verified=true;
			$e->verified($verified);
			$e->dbh($dbh);

			$upload=new Upload($vars->url_upload(),$_FILES['pc_upload']);
			$upload->uploaddir('upload');
			$e->file($upload->upload());

			$e->mysqlInsert();
			echo "<h4>{$vars->catname()} hinzugef&uuml;gt</h4>";
		}else {
			//nicht alle erforderlichen Variablen dabei
			echo "<h5>missing stuff:</h5>";
			foreach ($vars->missingVars()as $missing){
				echo $missing. ", ";
			}
		}
		/**Formular erzeugen***/
		$path=pathinfo(__FILE__);
		$form=new Formgen("post", $path['filename'].'.'.$path['extension']);
		$form->addTextField("Name", "catname");
		$form->addSelect("kategorie", "category",$category->mysqlSelect());
Beispiel #20
0
$path = htmlspecialchars($_POST['dir'], ENT_QUOTES);
//上传配置
$config = array(
    "savePath" => ($path == "1" ? "upload/" : "upload1/"),
    "maxSize" => 1000, //单位KB
    "allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp")
);
//生成上传实例对象并完成上传
$up = new Upload("upfile", $config);
/**
 * 得到上传文件所对应的各个参数,数组结构
 * array(
 * "originalName" => "", //原始文件名
 * "name" => "", //新文件名
 * "url" => "", //返回的地址
 * "size" => "", //文件大小
 * "type" => "" , //文件类型
 * "state" => "" //上传状态,上传成功时必须返回"SUCCESS"
 * )
 */
$info = $up->upload();
/**
 * 向浏览器返回数据json数据
 * {
 * 'url' :'a.jpg', //保存后的文件路径
 * 'title' :'hello', //文件描述,对图片来说在前端会添加到title属性上
 * 'original' :'b.jpg', //原始文件名
 * 'state' :'SUCCESS' //上传状态,成功时返回SUCCESS,其他任何值将原样返回至图片上传框中
 * }
 */
echo "{'url':'" . $info["url"] . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}"; 
 /**
  * 上传文件
  */
 public function upload()
 {
     $upload = new Upload('Upload/Content/' . date('y/m'));
     $file = $upload->upload();
     if (empty($file)) {
         $this->ajax('上传失败');
     } else {
         $data = $file[0];
         if ($data['image'] && C('WATER_ON')) {
             $imageObj = new Image();
             $imageObj->water($data['path'], $data['path']);
         }
         $data['uid'] = $_SESSION['user']['uid'];
         $data['mid'] = $this->mid;
         M('upload')->add($data);
         $this->ajax($data);
     }
 }
Beispiel #22
0
 public function uploadAction()
 {
     //echo "das";
     $upload = new Upload($config = array());
     $upload->upload();
 }
Beispiel #23
0
 public function uploadpicAction()
 {
     if (!empty($_FILES)) {
         $config = Yaf_Application::app()->getConfig()->upload->config->toArray();
         $ftpconfig = Yaf_Application::app()->getConfig()->ftp->config->toArray();
         $upload = new Upload($config, 'Ftp', $ftpconfig);
         $info = $upload->upload();
         if (!$info) {
             // 上传错误提示错误信息
             echo $upload->getError();
         } else {
             // 上传成功
             if (!empty($info["UpLoadFile"])) {
                 $pic = array("cate_pic" => $info["UpLoadFile"]['savepath'] . $info["UpLoadFile"]['savename']);
             }
             print_r($pic);
         }
     }
 }
Beispiel #24
0
			$e->codeLanguage($vars->language());

			
			if ($vars->verified()=='on'){
				$verified=true;
			}else {
				$verified='false';	
			}			
			
			
			$e->verified($verified);
			$e->dbh($dbh);

			$upload=new Upload($vars->url_upload(),$_FILES['pc_upload']);
			$upload->uploaddir('upload');		
			$newfile=$upload->upload();
			if($newfile!="" && $fileSet){					
				unlink($e->file());
			}
			$e->file($upload->upload());
			$e->mysqlUpdate();
			echo "<h4>{$vars->catname()} ge&auml;ndert :)</h4>";
		}else {
		;
		}
		/**Formular erzeugen***/


		$edit=new Getvars();
		$edit->requireVar('edit');
		
 /**
  * 上传文件
  */
 public function upload()
 {
     $upload = new Upload('Upload/Content/' . date('y/m'));
     $file = $upload->upload();
     if (empty($file)) {
         $this->ajax('上传失败');
     } else {
         $data = $file[0];
         $data['uid'] = $_SESSION['user']['uid'];
         $data['mid'] = $this->mid;
         M('upload')->add($data);
         $this->ajax($data);
     }
 }
 public function addArticle()
 {
     if (IS_POST) {
         if (empty($_POST['title']) || empty(strip_tags($_POST['details'], '<img>'))) {
             $this->error("文章内容或标题不能为空", U('addArticle'));
         }
         #p($_FILES);die;
         $data = array('title' => $_POST['title'], 'source' => $_POST['source'], 'tags' => $_POST['tags'], 'cid' => $_POST['cid'], 'display' => $_POST['display'], 'excerpt' => isset($_POST['excerpt']) ? $_POST['excerpt'] : substr(strip_tags($_POST['details']), 0, 150), 'details' => $_POST['details'], 'author' => isset($_POST['author']) ? $_POST['author'] : $_SESSION['username'], 'uid' => $_POST['uid']);
         //处理ajax上传图片的问题
         $reg = '/\\<img.*?src="(.*?)\\".*?>/is';
         preg_match_all($reg, $data['details'], $results);
         // p($results);die;
         if (count($results[0]) > 1) {
             // p($results[1]);die;
             foreach ($results[1] as $val) {
                 $dir = explode("/", $val);
                 $newDir = $dir[0] . "/ArticleImages/" . $dir[2] . "/" . $dir[3] . "/" . $dir[4];
                 $newFile = $newDir . "/" . $dir[5];
                 // $old = $dir[0]."/".$dir[1]."/".$dir[2];
                 if (Dir::create($newDir)) {
                     #p($val);
                     copy($val, $newFile);
                     Dir::del($val);
                     // Dir::del($old);
                 }
             }
         } elseif (count($results[0]) == 1) {
             //                    echo 1;
             $dir = explode("/", $results[1][0]);
             // p($dir);
             $newDir = $dir[0] . "/ArticleImages/" . $dir[2] . "/" . $dir[3] . "/" . $dir[4];
             $newFile = $newDir . "/" . $dir[5];
             // $old = $dir[0]."/".$dir[1]."/".$dir[2];
             if (Dir::create($newDir)) {
                 copy($results[1][0], $newFile);
                 Dir::del($results[1][0]);
                 // Dir::del($old);
             }
         } else {
             $this->error('文章已经上传成功,但是内容图片可能不能正常显示,请返回编辑');
         }
         $data['details'] = str_replace('Temp', 'ArticleImages', $data['details']);
         #p($_FILES);die;
         if (isset($_FILES['thumb'])) {
             $path = 'Upload/ArticleImages/' . date("Y/m/d");
             $upload = new Upload($path);
             $file = $upload->upload();
         }
         if ($file) {
             $data['thumb'] = $file[0]['path'];
             $data['create_time'] = time();
         } else {
             $this->error('图片上传不成功', U('addArticle'));
         }
         if (K('Article')->addArticle($data)) {
             #die;
             $this->success("文章添加成功", U('ucenter/alist', array('p' => 1, 'uid' => $data['uid'])));
         } else {
             $this->error('文章添加失败', U('addArticle'));
         }
     }
 }
<?php

// This class is needed for upload
require_once 'Upload.php';
// Create the instance and pass in the files array
$upload = new Upload($_FILES['files']);
// Set the upload directory
$upload->setDir('github/PHP-File-Multiupload/upload');
// Upload the files
$upload->upload();
Beispiel #28
0
$id = Url::getParam('id');
if (!empty($id)) {
    $objCatalogue = new Catalogue();
    $product = $objCatalogue->getProduct($id);
    if (!empty($product)) {
        $objForm = new Form();
        $objValid = new Validation($objForm);
        $categories = $objCatalogue->getCategories();
        if ($objForm->isPost('name')) {
            $objValid->_expected = array('category', 'name', 'description', 'price');
            $objValid->_required = array('category', 'name', 'description', 'price');
            if ($objValid->isValid()) {
                if ($objCatalogue->updateProduct($objValid->_post, $id)) {
                    $objUpload = new Upload();
                    if ($objUpload->upload(CATALOGUE_PATH)) {
                        if (is_file(CATALOGUE_PATH . DS . $product['image'])) {
                            unlink(CATALOGUE_PATH . DS . $product['image']);
                        }
                        $objCatalogue->updateProduct(array('image' => $objUpload->_names[0]), $id);
                        Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited');
                    } else {
                        Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited-no-upload');
                    }
                } else {
                    Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited-failed');
                }
            }
        }
        require_once 'template/_header.php';
        ?>
 public function uploadFace()
 {
     //关闭水印
     C('WATER_ON', false);
     $dir = 'upload/user/' . date("Y/m/d/");
     $upload = new Upload($dir);
     $file = $upload->upload();
     if (empty($file)) {
         $this->ajax(array('status' => 0, 'error' => $file->error));
     } else {
         $file = $file[0];
         $img = new Image();
         $img->thumb($file['path'], $file['path'], 250, 250, 6);
         $this->ajax(array('status' => 1, 'url' => $file['url'], 'path' => $file['path']));
     }
 }
Beispiel #30
0
 /** TODO: move this!!
  *
  * Multiple File upload  with database insert
  * @param string $user_file
  * @param array $config
  * @return array
  * @throws exception
  */
 public function upload_files($user_file = 'Files', $config = array())
 {
     $lAttachObj = new Upload();
     // load Upload lib
     $files = $_FILES;
     $cpt = count($_FILES[$user_file]['name']);
     for ($i = 0; $i < $cpt; $i++) {
         $_FILES[$user_file]['name'] = $files[$user_file]['name'][$i];
         $_FILES[$user_file]['type'] = $files[$user_file]['type'][$i];
         $_FILES[$user_file]['tmp_name'] = $files[$user_file]['tmp_name'][$i];
         $_FILES[$user_file]['error'] = $files[$user_file]['error'][$i];
         $_FILES[$user_file]['size'] = $files[$user_file]['size'][$i];
         // upload file
         $lAttachObj->initialize($config);
         $lAttachObj->upload($user_file);
         // db insert
         $lAttachObj->file_id = Files::insert($lAttachObj->file_model);
         $fileArrays[] = $lAttachObj->file_model;
         $attachObjArrays[] = clone $lAttachObj;
         // to generete proper return obj, we need to clone
     }
     $rtn = array('attachObjs' => $attachObjArrays, 'files' => $fileArrays);
     return $rtn;
 }