當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UploadFile::uploadOne方法代碼示例

本文整理匯總了PHP中UploadFile::uploadOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadFile::uploadOne方法的具體用法?PHP UploadFile::uploadOne怎麽用?PHP UploadFile::uploadOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UploadFile的用法示例。


在下文中一共展示了UploadFile::uploadOne方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: runAddVideo

 public function runAddVideo()
 {
     $Video = $_FILES[video];
     $Image = $_FILES[image];
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     $upload->maxSize = 100000000000;
     // 設置附件上傳大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg', 'bmp');
     // 設置附件上傳類型
     $upload->savePath = './Data/Image/';
     // 設置附件上傳目錄
     //上傳圖片
     if (!($imageInfo = $upload->uploadOne($Image, $savePath = './Data/Image/'))) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     }
     //上傳視頻
     $upload->allowExts = array('flv', 'mp4', 'rmvb');
     // 設置附件上傳類型
     if (!($videoInfo = $upload->uploadOne($Video, $savePath = './Data/Video/'))) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     }
     $data = $_POST;
     var_dump($data);
     die;
     $data['image'] = $imageInfo[0]['savename'];
     $data['video'] = $videoInfo[0]['savename'];
     $data['time'] = date('Y-m-d', strtotime("now"));
     $data['author'] = 'admin';
     if (M('video')->add($data)) {
         $this->success('添加成功');
     }
 }
開發者ID:ahpuchunwei,項目名稱:LCOS,代碼行數:35,代碼來源:VideoAction.class.php

示例2: upload

 /**
  * 上傳文件
  * @param Array     $filename 表單file控件的name屬性
  * @param String   $type   上傳文件類型  
  * @param Array $aOtherConfig 其他配置參數
  * @return Array	  上傳成功返回文件保存信息,失敗返回錯誤信息
  */
 public function upload($filename = 'filename', $type = 'image', $aOtherConfig = array())
 {
     //上傳文件配置
     $aUploadConfig = array('image' => array('allowExts' => array('jpg', 'gif', 'png', 'jpeg'), 'maxSize' => 3145728, 'savePath' => C('TMPL_PARSE_STRING.__FILES__') . '/image/', 'basePath' => '/image/'), 'audio' => array('allowExts' => array('aac', 'mp3'), 'maxSize' => 3145728, 'savePath' => C('TMPL_PARSE_STRING.__FILES__') . '/audio/', 'basePath' => '/audio/'), 'face' => array('allowExts' => array('jpg', 'gif', 'png', 'jpeg'), 'maxSize' => 3145728, 'savePath' => C('TMPL_PARSE_STRING.__FILES__') . '/face/', 'basePath' => '/face/', 'thumb' => true, 'thumbMaxWidth' => '24,48,120', 'thumbMaxHeight' => '24,48,120', 'thumbSuffix' => '_24-24,_48-48,_120-120'));
     $public_config = array('autoSub' => true, 'subType' => 'date', 'saveRule' => 'uniqid', 'thumbPrefix' => '');
     $custom_config = $aUploadConfig[$type];
     if (!empty($aOtherConfig)) {
         $custom_config = array_merge($custom_config, $aOtherConfig);
     }
     $config = array_merge($public_config, $custom_config);
     import('ORG.Net.UploadFile');
     //引入上傳類
     $upload = new UploadFile($config);
     //執行上傳
     $info = $upload->uploadOne($_FILES[$filename]);
     //執行上傳操作
     if (!$info) {
         // 上傳錯誤提示錯誤信息
         return array('status' => 1001, 'msg' => $upload->getErrorMsg());
     } else {
         // 上傳成功 獲取上傳文件信息
         $info = $info[0];
         //添加數據庫記錄
         $data = array('appid' => $this->oApp->id, 'name' => $info['name'], 'type' => $info['type'], 'extension' => $info['extension'], 'thumbs' => str_replace('_', '', $config['thumbSuffix']), 'size' => $info['size'], 'base_url' => $config['basePath'] . $info['savename'], 'status' => 0, 'createtime' => time());
         $info['fileid'] = $this->add($data);
         return array('status' => 0, 'msg' => '上傳成功!', 'data' => $info);
     }
 }
開發者ID:omusico,項目名稱:jianli,代碼行數:35,代碼來源:FileModel.class.php

示例3: editor_up

 public function editor_up()
 {
     //$savePath 為項目下的上傳目錄名 如 uploads 會是 上傳到__ROOR__/uploads下,為空則上傳到__ROOT__/uploads/thinkeditor下
     // $saveRule為上傳文件命名規則,例如可以是 time uniqid com_create_guid 等,例如可以是 time uniqid com_create_guid 等 默認為time參考tp的上傳類
     // 例如可以是 time uniqid com_create_guid 等
     $savePath = 'uploads';
     $saveRule = 'time';
     import("@.ORG.UploadFile");
     $savePath = $savePath ? './' . $savePath : './Uploads/thinkeditor';
     $savePath = substr($savePath, -1) != '/' ? $savePath . '/' : $savePath;
     $maxSize = $_POST['temaxsize'] ? $_POST['temaxsize'] : -1;
     $upload = new UploadFile($maxSize, '', '', $savePath, $saveRule);
     //傳給js的參數 $savepath是上傳的文件的生成路徑,$isupload是上傳是否成功的布爾值
     $savepath = '';
     $isupload = 'false';
     if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
         $info = $upload->uploadOne($_FILES['teupload']);
         if ($info) {
             $isupload = 'true';
             $savepath = $upload->savePath . $info[0]['savename'];
             $savepath = substr($savepath, 1);
         } else {
             $error = $upload->getErrorMsg();
         }
     }
     import('@.TagLib.TagLibTp');
     //上麵的上傳隻是寫個例子,用戶上傳可以自定義的,但是下麵的是傳給編輯器的
     //參數必須為$isupload,是否成功,上傳後的文件相對路徑$savepath必須相對於項目根目錄的,錯誤信息
     TagLibTp::think_upload($isupload, $savepath, $error);
 }
開發者ID:zjstage,項目名稱:ThinkPHP,代碼行數:30,代碼來源:PublicAction.class.php

示例4: upload_file

 /**
  * 上傳文件
  * @param Array    $file  $_FILES['pic']	  上傳的數組
  * @param String   $type   上傳文件類型    pic為圖片
  * @return Array	  上傳成功返回文件保存信息,失敗返回錯誤信息
  */
 protected function upload_file($file, $dir, $size = 3145728, $type = array('jpg', 'gif', 'png', 'jpeg'))
 {
     import('@.ORG.Util.UploadFile');
     //引入上傳類
     $upload = new UploadFile();
     $upload->maxSize = $size;
     // 設置附件上傳大小
     $upload->allowExts = $type;
     // 上傳文件的(後綴)(留空為不限製),,
     //上傳保存
     $upload->savePath = $dir;
     // 設置附件上傳目錄
     $upload->autoSub = true;
     // 是否使用子目錄保存上傳文件
     $upload->subType = 'date';
     // 子目錄創建方式,默認為hash,可以設置為hash或者date日期格式的文件夾名
     $upload->saveRule = 'uniqid';
     // 上傳文件的保存規則,必須是一個無需任何參數的函數名
     //執行上傳
     $execute = $upload->uploadOne($file);
     //執行上傳操作
     if (!$execute) {
         // 上傳錯誤提示錯誤信息
         return array('status' => false, 'info' => $upload->getErrorMsg());
     } else {
         //上傳成功 獲取上傳文件信息
         return array('status' => true, 'info' => $execute);
     }
 }
開發者ID:cyndiWade,項目名稱:xintuo,代碼行數:35,代碼來源:HtmlBaseAction.class.php

示例5: upload

 /**
  * 單個文件上傳
  *
  * @param [type]  $fileFields [description]
  * @return [type]             [description]
  */
 public static function upload($fileFields, $params = false)
 {
     $conf = Config::get('', 'base');
     $params['thumbSize'] = array(400, 400);
     Yii::import('application.vendors.*');
     require_once 'Tp/UploadFile.class.php';
     $upload = new UploadFile();
     // 設置上傳文件大小
     $maxSize = isset($params['maxSize']) ? $params['maxSize'] : $conf['upload_max_size'];
     $upload->maxSize = $maxSize * 1024;
     // 設置上傳文件類型
     $upload->allowExts = isset($params['allowExts']) ? explode(',', $params['allowExts']) : explode(',', $conf['upload_allow_ext']);
     // 設置附件上傳目錄
     $upload->savePath = self::_saveRule($params['saveRule']);
     // 設置需要生成縮略圖,僅對圖像文件有效
     $upload->thumb = isset($params['thumb']) ? $params['thumb'] : $conf['thumb'];
     // 設置需要生成縮略圖的文件後綴
     $upload->thumbPrefix = 'thumb_';
     // 生產2張縮略圖
     // 設置縮略圖最大寬度
     $upload->thumbMaxWidth = $params['thumbSize'][0];
     // 設置縮略圖最大高度
     $upload->thumbMaxHeight = $params['thumbSize'][1];
     // 設置上傳文件規則
     $upload->saveRule = md5(time() . mt_rand(5, 15));
     // 刪除原圖
     $upload->thumbRemoveOrigin = false;
     $file = $upload->uploadOne($fileFields);
     if (!is_array($file)) {
         return $upload->getErrorMsg();
     } else {
         // 重新整理返回數據
         $fileget['name'] = $file[0]['name'];
         $fileget['type'] = $file[0]['type'];
         $fileget['size'] = $file[0]['size'];
         $fileget['extension'] = $file[0]['extension'];
         $fileget['savepath'] = $file[0]['savepath'];
         $fileget['savename'] = $file[0]['savename'];
         $fileget['hash'] = $file[0]['hash'];
         $fileget['pathname'] = $upload->savePath . $file[0]['savename'];
         if ($conf['upload_water_status'] == 'open') {
             require_once 'Tp/Image.class.php';
             Image::water($fileget['pathname'], './' . $conf['upload_water_file'], null, $conf['upload_water_trans']);
         }
         // 縮略圖返回
         if (true == $upload->thumb) {
             $fileget['thumb'] = $upload->thumbPrefix . $file[0]['savename'];
             $fileget['paththumbname'] = $upload->savePath . $upload->thumbPrefix . $file[0]['savename'];
         }
         return $fileget;
     }
 }
開發者ID:bigbol,項目名稱:ziiwo,代碼行數:58,代碼來源:XUpload.php

示例6: upload

 /**
  * 單個文件上傳
  *
  * @param [type]  $fileFields [description]
  * @return [type]             [description]
  */
 public static function upload($fileFields, $params = array('thumb' => false, 'thumbSize' => array(400, 400), 'allowExts' => 'jpg,gif,png,jpeg', 'maxSize' => 3292200))
 {
     Yii::import('application.vendor.*');
     require_once 'Tp/UploadFile.class.php';
     $upload = new UploadFile();
     // 設置上傳文件大小
     $upload->maxSize = isset($params['maxSize']) ? $params['maxSize'] : Config::get('maxSize');
     // 設置上傳文件類型
     $upload->allowExts = isset($params['allowExts']) ? explode(',', $params['allowExts']) : explode(',', Config::get('upload_allow_ext'));
     // 設置附件上傳目錄
     empty($params['saveRule']) && ($params['saveRule'] = array('rule' => 'default', 'format' => 'Ymd', 'path' => 'uploads/'));
     $upload->savePath = self::_saveRule($params['saveRule']);
     if ($params['thumb']) {
         // 設置需要生成縮略圖,僅對圖像文件有效
         $upload->thumb = isset($params['thumb']) ? $params['thumb'] : Config::get('thumb');
         // 設置需要生成縮略圖的文件後綴
         $upload->thumbPrefix = 'thumb_';
         // 生產2張縮略圖
         // 設置縮略圖最大寬度
         $upload->thumbMaxWidth = $params['thumbSize'][0];
         // 設置縮略圖最大高度
         $upload->thumbMaxHeight = $params['thumbSize'][1];
     }
     // 設置上傳文件規則
     $upload->saveRule = 'uniqid';
     // 刪除原圖
     $upload->thumbRemoveOrigin = false;
     $file = $upload->uploadOne($fileFields);
     if (!is_array($file)) {
         return $upload->getErrorMsg();
     } else {
         // 重新整理返回數據
         $fileget['name'] = $file[0]['name'];
         $fileget['type'] = $file[0]['type'];
         $fileget['size'] = $file[0]['size'];
         $fileget['extension'] = $file[0]['extension'];
         $fileget['savepath'] = $file[0]['savepath'];
         $fileget['savename'] = $file[0]['savename'];
         $fileget['hash'] = $file[0]['hash'];
         $fileget['pathname'] = $upload->savePath . $file[0]['savename'];
         if (Config::get('upload_water_status') == 'open') {
             require_once 'Tp/Image.class.php';
             Image::water($fileget['pathname'], './' . Config::get('upload_water_file'), null, Config::get('upload_water_trans'));
         }
         // 縮略圖返回
         if (true == $upload->thumb) {
             $fileget['thumb'] = $upload->thumbPrefix . $file[0]['savename'];
             $fileget['paththumbname'] = $upload->savePath . $upload->thumbPrefix . $file[0]['savename'];
         }
         return $fileget;
     }
 }
開發者ID:lp19851119,項目名稱:114la,代碼行數:58,代碼來源:XUpload.php

示例7: import

 function upload_pic($file, $type, $thumb = true, $water = false, $thumbPrefix = 'm_,s_', $thumbMaxWidth = '757,77', $thumbMaxHeight = '426,58')
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //    	$uploadList = array();
     //    	foreach($pics as $key=>$file)
     //    	{
     if (!empty($file['name'])) {
         //設置上傳文件大小
         $upload->maxSize = 2 * 1024 * 1024;
         //設置上傳文件類型
         $upload->allowExts = explode(',', $type);
         $save_dir = "Uploads/pic/loginImg/" . date('Y') . '/' . date('Ymd');
         //創建文件夾
         @$this->create_dir($save_dir);
         //設置附件上傳目錄
         $upload->savePath = $save_dir . '/';
         //設置上傳文件規則
         $upload->saveRule = uniqid;
         //設置需要生成縮略圖,僅對圖像文件有效
         $upload->thumb = $thumb;
         // 設置引用圖片類庫包路徑
         $upload->imageClassPath = 'ORG.Util.Image';
         //設置需要生成縮略圖的文件後綴
         $upload->thumbPrefix = $thumbPrefix;
         //生產2張縮略圖
         //設置縮略圖最大寬度
         $upload->thumbMaxWidth = $thumbMaxWidth;
         //$upload->thumbMaxWidth = '414,311';
         //設置縮略圖最大高度
         $upload->thumbMaxHeight = $thumbMaxHeight;
         //$upload->thumbMaxHeight = '414,311';
         $upload->thumbRemoveOrigin = false;
         //不刪除原圖
         $info = $upload->uploadOne($file);
         if ($info) {
             //取得成功上傳的文件信息
             $uploadInfo = $info;
         } else {
             //捕獲上傳異常
             $this->error($upload->getErrorMsg());
         }
     }
     //    	}
     //返回數據對象
     return $uploadInfo;
 }
開發者ID:ycltpe,項目名稱:sig,代碼行數:47,代碼來源:LoginImgAction.class.php

示例8: xheditorUpImg

 public function xheditorUpImg()
 {
     require_once CLASS_DIR . 'UploadFile.class.php';
     $upload = new UploadFile();
     $upload->maxSize = 1 * 1024 * 1024;
     //1M 設置上傳大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg', 'bmp');
     //設置上傳類型
     $upload->savePath = 'upload/xheditor/' . date('Ym') . '/';
     // 設置上傳目錄
     $upload->saveRule = date("YmdHis");
     //上傳文件的保存規則
     print_r($upload->getUploadFileInfo());
     if (!$upload->uploadOne($_FILES['filedata'])) {
         $error = $upload->getErrorMsg();
         $statusCode = 300;
         $message = '上傳失敗,請重新上傳';
     } else {
         $message = '恭喜您,上傳成功';
         $statusCode = 200;
         $uploadList = $upload->getUploadFileInfo();
         $img = '/' . $upload->savePath . $uploadList[0]['savename'];
         //返回上傳的目錄
     }
     $return = array();
     if ($_REQUEST['type'] == 'uploadify') {
         //需要在jquery.uploadify.js中配置上傳的文件
         $return['statusCode'] = $statusCode;
         $return['message'] = $message;
         $return['url'] = $img;
         $return['navTabId'] = "";
         $return['rel'] = "";
         $return['callbackType'] = "";
         $return['forwardUrl'] = "";
         $return['confirmMsg'] = "";
     } else {
         $return['err'] = $error;
         $return['msg'] = $img;
     }
     echo json_encode($return);
     exit;
 }
開發者ID:13240361944,項目名稱:analyze,代碼行數:42,代碼來源:ajaxAction.class.php

示例9: upload

 public function upload()
 {
     //導入上傳類
     import('ORG.Net.UploadFile');
     //初始化上傳類並進行一些配置
     $upload = new UploadFile();
     $upload->maxSize = 3145728;
     $upload->allowExts = array('xls', 'xlsx');
     $upload->savePath = __ROOT__ . '/Public/upload/';
     //上傳文件並返回文件信息
     $info = $upload->uploadOne($_FILES['excelData']);
     //保存文件路徑
     $filename = $info[0]['savepath'] . $info[0]['savename'];
     //保存文件擴展名
     $extension = $info[0]['extension'];
     //判斷是否上傳成功,若否,拋出對應錯誤
     if (!$info) {
         $this->error($upload->getErrorMsg());
     } else {
         $this->read_excel($filename, $extension);
     }
 }
開發者ID:Encore777,項目名稱:meeting,代碼行數:22,代碼來源:ExcelAction.class.php

示例10: _uploadone

 private function _uploadone($imgage, $path = '', $isThumb = true)
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //設置上傳文件大小
     $upload->maxSize = 3292200;
     $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
     if (empty($path)) {
         $upload->savePath = './data/items/';
     } else {
         $upload->savePath = $path;
     }
     if ($isThumb === true) {
         $upload->thumb = true;
         $upload->imageClassPath = 'ORG.Util.Image';
         $upload->thumbPrefix = 'm_';
         $upload->thumbMaxWidth = '450';
         //設置縮略圖最大高度
         $upload->thumbMaxHeight = '450';
         $upload->saveRule = uniqid;
         $upload->thumbRemoveOrigin = true;
     }
     if (!$upload->uploadOne($imgage)) {
         //捕獲上傳異常
         $this->error($upload->getErrorMsg());
     } else {
         //取得成功上傳的文件信息
         $uploadList = $upload->getUploadFileInfo();
     }
     return $uploadList;
 }
開發者ID:nexteee,項目名稱:php,代碼行數:31,代碼來源:ucAction.class.php

示例11: edituppic

 public function edituppic()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = 5242880;
     // 設置附件上傳大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     // 設置附件上傳類型
     $upload->savePath = './uploads/pic/' . date('Ym') . '/';
     // 設置附件上傳目錄
     $upload->thumb = true;
     $upload->thumbType = 0;
     $upload->thumbPrefix = 'b_,s_';
     $upload->thumbMaxWidth = '500,150';
     $upload->thumbMaxHeight = '1000,150';
     $upload->thumbRemoveOrigin = true;
     $upload->saveRule = time() . '_' . mt_rand(1000000, 9999999);
     $info = $upload->uploadOne($_FILES['imgFile']);
     $file_url = '/uploads/pic/' . date('Ym') . '/b_' . $info['0']['savename'];
     if ($info) {
         $data['error'] = 0;
         $data['url'] = $file_url;
         $this->ajaxReturn($data, 'JSON');
     } else {
         $this->ajaxReturn(0, $upload->getErrorMsg(), 0);
     }
 }
開發者ID:easley999,項目名稱:tzj,代碼行數:28,代碼來源:UpperAction.class.php

示例12: catch

 }
 $db = Db::getInstance();
 try {
     $db->connect();
 } catch (Exception $e) {
     echo getJsonResponse(1, '數據庫連接錯誤', null);
     Log::error_log("數據庫連接錯誤");
     exit;
 }
 if (!checkUserToken($db, $_POST['user_id'], $_POST['access_token'])) {
     echo getJsonResponse(2, '用戶token錯誤', null);
     exit;
 }
 $config1 = array('maxSize' => 2100000, 'allowExts' => array('png', 'jpg'), 'allowTypes' => array('image/png', 'image/jpeg'), 'savePath' => '../images/users/');
 $uf = new UploadFile($config1);
 $res = $uf->uploadOne($_FILES['image']);
 if ($res) {
     $savePath = 'http://' . getServerIp() . '/images/users/' . $res['savename'];
     if (false !== $db->execute("update users set imageurl='{$savePath}' where user_id={$_POST['user_id']};")) {
         echo getJsonResponse(0, '上傳成功', null);
     } else {
         echo getJsonResponse(1, $db->error, null);
     }
     $db->close();
 } else {
     if ($uf->errorNo == 1 || $uf->errorNo == 2 || $uf->errorNo == 8) {
         echo getJsonResponse(3, $uf->errorMsg, null);
     } else {
         if ($uf->errorNo == 9) {
             echo getJsonResponse(4, $uf->errorMsg, null);
         } else {
開發者ID:xiaoqinzhe,項目名稱:eatBetter,代碼行數:31,代碼來源:head_picture_upload.php

示例13: import

 function upload_pic($file, $type, $path, $thumb = false, $water = false, $thumbPrefix = 's_', $thumbMaxWidth = '125', $thumbMaxHeight = '125')
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     if (!empty($file['name'])) {
         //設置上傳文件大小
         $upload->maxSize = 1 * 1024 * 1024;
         //設置上傳文件類型
         $upload->allowExts = explode(',', $type);
         $save_dir = $path . date('Y') . '/' . date('Ymd');
         //創建文件夾
         @$this->create_dir($save_dir);
         //設置附件上傳目錄
         $upload->savePath = $save_dir . '/';
         //設置上傳文件規則
         $upload->saveRule = uniqid;
         $info = $upload->uploadOne($file);
         if ($info) {
             //取得成功上傳的文件信息
             $uploadInfo = $info;
         } else {
             //捕獲上傳異常
             $this->error($upload->getErrorMsg());
         }
     }
     //返回數據對象
     return $uploadInfo;
 }
開發者ID:ycltpe,項目名稱:sig,代碼行數:28,代碼來源:StoreManagerAction.class.php

示例14: _upload

 private function _upload($imgage, $path = '', $isThumb = false)
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //設置上傳文件大小
     $upload->maxSize = 3292200;
     $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
     $upload->saveRule = uniqid;
     if (empty($savePath)) {
         $upload->savePath = ROOT_PATH . '/data/items_cate/';
     } else {
         $upload->savePath = $path;
     }
     if (!$upload->uploadOne($imgage)) {
         //捕獲上傳異常
         $this->error($upload->getErrorMsg());
     } else {
         //取得成功上傳的文件信息
         $uploadList = $upload->getUploadFileInfo();
     }
     return $uploadList;
 }
開發者ID:nexteee,項目名稱:php,代碼行數:22,代碼來源:items_cateAction.class.php

示例15: ajaxupimg2

 public function ajaxupimg2()
 {
     // if($this->uid!=$_POST['uid'])
     // {
     // 	ajaxmsg('數據有誤!',0);
     // }
     if (!empty($_FILES['imgfile2']['name'])) {
         import('ORG.Net.UploadFile');
         $upload = new UploadFile();
         // 實例化上傳類
         $upload->maxSize = 3145728;
         // 設置附件上傳大小
         $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
         // 設置附件上傳類型
         $upload->savePath = './UF/Uploads/Idcard/';
         // 設置附件上傳目錄
         chmod($upload->savePath, 0777);
         $upload->saveRule = date("YmdHis", time()) . rand(0, 1000) . "_{$this->uid}";
         foreach ($_FILES as $key => $file) {
             if (!empty($file['name'])) {
                 $upload->autoSub = true;
                 $upload->subType = 'date';
                 $info = $upload->uploadOne($file);
                 if ($info) {
                     // 保存附件信息
                     M('Photo')->add($info);
                 } else {
                     // 上傳錯誤
                     ajaxmsg($upload->getErrorMsg(), 0);
                 }
             }
         }
         //$info = $this->CUpload();
         $img = $info[0]['savepath'] . $info[0]['savename'];
         //$img[1] = $info[1]['savepath'].$info[1]['savename'];
     }
     if ($img) {
         $c = M('member_info')->where("uid = {$this->uid}")->count('uid');
         if ($c == 1) {
             //$newid = M("member_info")->where("uid={$this->uid}")->setField('card_img',$img[0]);
             //$newid = M("member_info")->where("uid={$this->uid}")->setField('card_back_img',$img[1]);
             $newid = M("member_info")->where("uid={$this->uid}")->setField('card_back_img', $img);
         } else {
             $data['uid'] = $this->uid;
             //$data['card_img'] = $img[0];
             $data['card_back_img'] = $img;
             $newid = M('member_info')->add($data);
         }
         session("idcardimg2", "1");
         ajaxmsg('上傳成功', 1);
     } else {
         ajaxmsg('上傳失敗,請重試', 0);
     }
 }
開發者ID:caotieshuan,項目名稱:ishoutou,代碼行數:54,代碼來源:VerifyAction.class.php


注:本文中的UploadFile::uploadOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。