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


PHP UploadFile::getErrorMsg方法代碼示例

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


在下文中一共展示了UploadFile::getErrorMsg方法的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: upimg

 public function upimg($path, $width = '300', $height = '150')
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     $upload->maxSize = '2048000';
     $upload->savePath = $path;
     $upload->saveRule = uniqid;
     $upload->allowExts = array('jpg', 'jpeg', 'png', 'gif', 'bmp');
     //$upload->allowTypes=array('','','','','','');
     //	是否生成縮略圖
     $upload->thumb = true;
     $upload->thumbMaxWidth = $width;
     $upload->thumbMaxHeight = $height;
     //	縮略圖前綴
     $upload->thumbPrefix = 'a';
     //	是否刪除原圖
     $upload->thumbRemoveOrigin = true;
     //	調用上傳方法
     if ($upload->upload()) {
         //	成功則返回對應信息用於之後的調用
         $info = $upload->getUploadFileInfo();
         return $info;
     } else {
         $this->error($upload->getErrorMsg());
     }
 }
開發者ID:highestgoodlikewater,項目名稱:3600KR,代碼行數:26,代碼來源:ArticleAction.class.php

示例3: up

 private function up()
 {
     //完成與thinkphp相關的,文件上傳類的調用
     import('@.Org.UploadFile');
     //將上傳類UploadFile.class.php拷到Lib/Org文件夾下
     $upload = new UploadFile();
     $upload->maxSize = '1000000';
     //默認為-1,不限製上傳大小
     $upload->savePath = './Data/upload/';
     //保存路徑建議與主文件平級目錄或者平級目錄的子目錄來保存
     $upload->saveRule = uniqid;
     //上傳文件的文件名保存規則
     $upload->uploadReplace = true;
     //如果存在同名文件是否進行覆蓋
     $upload->allowExts = array('jpg', 'jpeg', 'gif', 'png', 'xls', 'xlsx', 'rar', 'zip', 'ppt', 'doc', 'docx');
     //準許上傳的文件類型
     $upload->allowTypes = array('image/png', 'image/jpg', 'image/jpeg', 'image/gif');
     //檢測mime類型
     $upload->thumb = true;
     //是否開啟圖片文件縮略圖
     $upload->thumbMaxWidth = '300,500';
     $upload->thumbMaxHeight = '200,400';
     $upload->thumbPrefix = 's_,m_';
     //縮略圖文件前綴
     $upload->thumbRemoveOrigin = 1;
     //如果生成縮略圖,是否刪除原圖
     if ($upload->upload()) {
         $info = $upload->getUploadFileInfo();
         return $info;
     } else {
         $this->error($upload->getErrorMsg());
         //專門用來獲取上傳的錯誤信息的
     }
 }
開發者ID:yakrsa,項目名稱:football,代碼行數:34,代碼來源:FileAction.class.php

示例4: upload

 public function upload($id = 0)
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = 3145728;
     // 設置附件上傳大小
     $upload->allowExts = array('jpg');
     // 設置附件上傳類型
     $upload->savePath = '/var/www/html/goj/Tpl/Public/Uploads/';
     // 設置附件上傳目錄
     $name = time() . '_' . mt_rand();
     $upload->saveRule = $name;
     if (!$upload->upload()) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上傳成功
         if ($id == 0) {
             $this->success('上傳成功!', 'http://222.202.171.23/Problem/add/img/' . $name);
         } else {
             $this->success('上傳成功!', 'http://222.202.171.23/Problem/edit/id/' . $id . '/img/' . $name);
         }
     }
 }
開發者ID:hantianyang,項目名稱:GDUFE_OJ,代碼行數:25,代碼來源:UploadAction.class.php

示例5: saveBasic_Pic

 public function saveBasic_Pic()
 {
     $sqlGood = new sql_goodMod();
     $g_id = $this->in_post('id', None, 1, 'True');
     $a_id = $this->in_cookie('aid', None, 1, 'True');
     $upload = new UploadFile();
     //設置上傳文件大小
     $upload->maxSize = 1024 * 1024 * 2;
     //最大2M
     //設置上傳文件類型
     $upload->allowExts = explode(',', 'jpg,gif,png');
     //設置附件上傳目錄
     $upload->savePath = '../public/image/';
     $upload->saveRule = cp_uniqid;
     if (!$upload->upload()) {
         //捕獲上傳異常
         $error_res = $this->error($upload->getErrorMsg());
         dump($error_res);
     } else {
         //取得成功上傳的文件信息
         $up_res = $upload->getUploadFileInfo();
     }
     $ex_path = 'image/';
     $update_res = $sqlGood->set_brand_info_pic($a_id, $g_id, $ex_path . $up_res[0]['savename']);
     if ($update_res) {
         $this->alert('更新成功');
     } else {
         $this->alert('更新失敗');
     }
 }
開發者ID:heYeCheng,項目名稱:manager,代碼行數:30,代碼來源:brandMod.class.php

示例6: _upload

 protected function _upload()
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     $upload->maxSize = 1000000;
     //設置上傳文件大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     //設置上傳文件類型
     $upload->savePath = './Public/Upload/';
     //設置附件上傳目錄
     $upload->thumb = true;
     //設置需要生成縮略圖,僅對圖像文件有效
     $upload->thumbPrefix = 'wap120_,wap160_';
     //設置需要生成縮略圖的文件後綴
     $upload->thumbMaxWidth = '300,300';
     //設置縮略圖最大寬度
     $upload->thumbMaxHeight = '100,160';
     //設置縮略圖最大高度
     $upload->saveRule = uniqid;
     //設置上傳文件規則
     $upload->thumbRemoveOrigin = false;
     //刪除原圖
     if (!$upload->upload()) {
         $error = $upload->getErrorMsg();
         $this->error("對不起,圖片上傳出錯,錯誤信息:{$error}");
     } else {
         $photo = $upload->getUploadFileInfo();
         $db = new WorldsModel();
         $data['text'] = '[PIC]';
         $data['time'] = date("Y-m-d H:i:s");
         $data['iswap'] == 1;
         $_SESSION['w_id'] = $db->add($data);
         $this->savePic($photo, $_SESSION['w_id']);
     }
 }
開發者ID:cjmi,項目名稱:miniblog,代碼行數:35,代碼來源:PicAction.class.php

示例7: ueditorUpload

 public function ueditorUpload()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = 2 * 1024 * 1024;
     //設置上傳圖片的大小
     $upload->allowExts = array('jpg', 'png', 'gif');
     //設置上傳圖片的後綴
     $upload->autoSub = true;
     //是否使用子目錄保存上傳文件
     $upload->subType = 'date';
     //子目錄創建方式,默認為hash,可以設置為hash或者date
     $upload->dateFormat = 'Ym';
     //子目錄方式為date的時候指定日期格式
     $upload->savePath = C('UPLOAD_PATH');
     // 設置附件上傳目錄
     if ($upload->upload()) {
         $uploadInfo = $upload->getUploadFileInfo();
         $res = array('state' => 'SUCCESS', 'title' => htmlspecialchars($_POST['pictitle'], ENT_QUOTES), 'url' => $uploadInfo[0]['savename'], 'original' => $uploadInfo[0]['name'], 'filetype' => $uploadInfo[0]['extension'], 'size' => $uploadInfo[0]['size'], 'savename' => $uploadInfo[0]['savename']);
     } else {
         $res = array('state' => $upload->getErrorMsg());
     }
     echo json_encode($res);
     exit;
 }
開發者ID:hanngao,項目名稱:ResumeManagementSystem,代碼行數:26,代碼來源:IndexAction.class.php

示例8: add

 public function add()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = -1;
     // 設置附件上傳大小
     $upload->allowExts = array();
     // 設置附件上傳類型
     $upload->savePath = './Public/Uploads/apply/';
     // 設置附件上傳目錄
     if (!$upload->upload()) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上傳成功 獲取上傳文件信息
         $info = $upload->getUploadFileInfo();
     }
     // 保存表單數據 包括附件數據
     $join = M("join");
     // 實例化對象
     $user = M('user');
     $data = array('uid' => $_SESSION['uid'], 'people1' => $_POST['people1'], 'people2' => $_POST['people2'], 'phone1' => $_POST['phone1'], 'phone2' => $_POST['phone2'], 'email' => $_POST['email'], 'timeid' => $_POST['timeid'], 'file' => $info[0]['savename']);
     $updata = array('id' => $_SESSION['uid'], 'class' => '2');
     //p($data);die;
     //$User->img = $info[0]['savename']; // 保存上傳的照片根據需要自行組裝
     if ($join->add($data) && $user->save($updata)) {
         $this->success('數據保存成功!請重新登錄', U(GROUP_NAME . '/Login/index'));
     } else {
         $this->error('失敗');
     }
 }
開發者ID:omusico,項目名稱:Thinkphp_RMS,代碼行數:32,代碼來源:ApplyAction.class.php

示例9: addvedio

 public function addvedio()
 {
     $zhang_id = $_POST['zhang_id'];
     $vedio_title = $_POST['vedio_title'];
     $course_id = $_POST['course_id'];
     $upload = new UploadFile($_POST['file']);
     $upload->allowExts = array('mp4');
     $upload->savePath = './../Public/Uploads/vedio/';
     if (!$upload->upload()) {
         $this->error($upload->getErrorMsg());
     } else {
         $info = $upload->getUploadFileInfo();
         $vedio = M('vedio');
         $vedio->create();
         $vedio->vedio_title = $vedio_title;
         $vedio->vedio_name = $info[0]['savename'];
         $vedio->zhang_id = $zhang_id;
         $result = $vedio->add();
         $this->assign("jumpUrl", "__APP__/Vedio/index/id/{$course_id}");
         if ($result) {
             $this->success("添加成功!");
         } else {
             $this->error("添加不成功");
         }
     }
 }
開發者ID:highestgoodlikewater,項目名稱:class-website,代碼行數:26,代碼來源:VedioAction.class.php

示例10: index

 public function index()
 {
     @header("Content-Type:text/html; charset=utf-8");
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = 3145728;
     // 設置附件上傳大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     // 設置附件上傳類型
     $savepath = '../uploads/' . date('Ymd') . '/';
     $savepath1 = '/uploads/' . date('Ymd') . '/';
     if (!file_exists($savepath)) {
         mkdir($savepath);
     }
     $upload->savePath = $savepath;
     // 設置附件上傳目錄
     if (!$upload->upload()) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上傳成功 獲取上傳文件信息
         $info = $upload->getUploadFileInfo();
     }
     print_r($savepath1 . $info[0]['savename']);
 }
開發者ID:nathan1217,項目名稱:ccad,代碼行數:26,代碼來源:UploadAction.class.php

示例11: localupload

	public function localupload(){
		$upload = new UploadFile();
		$upload->allowExts  = array('pem');
		//覆蓋同名的文件
		$upload->uploadReplace=1;
        $firstLetter=substr($this->token,0,1);
        $upload->savePath =  './uploads/'.$firstLetter.'/'.$this->token.'/';// 設置附件上傳目錄
        //
        if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/uploads')||!is_dir($_SERVER['DOCUMENT_ROOT'].'/uploads')){
            mkdir($_SERVER['DOCUMENT_ROOT'].'/uploads',0777);
        }
        $firstLetterDir=$_SERVER['DOCUMENT_ROOT'].'/uploads/'.$firstLetter;
        if (!file_exists($firstLetterDir)||!is_dir($firstLetterDir)){
            mkdir($firstLetterDir,0777);
        }
        if (!file_exists($firstLetterDir.'/'.$this->token)||!is_dir($firstLetterDir.'/'.$this->token)){
            mkdir($firstLetterDir.'/'.$this->token,0777);
        }
		if(!file_exists($upload->savePath)||!is_dir($upload->savePath)){
			mkdir($upload->savePath,0777);
		}
       // $upload->hashLevel=2;
        if(!$upload->upload()) {// 上傳錯誤提示錯誤信息
            $error=1;
            $msg=$upload->getErrorMsg();
			$this->error($msg);exit;
        }else{// 上傳成功 獲取上傳文件信息
            $error=0;
            $info =  $upload->getUploadFileInfo();
            $this->siteUrl=$this->siteUrl?$this->siteUrl:C('site_url');
			$msg=$this->siteUrl.substr($upload->savePath,1).$info[0]['savename'];
			//成功入庫
			$this->addCert($info[0]['key'],$msg);
        }
	}
開發者ID:kevicki,項目名稱:pig,代碼行數:35,代碼來源:Alipay_certAction.class.php

示例12: uploadimg

 public function uploadimg()
 {
     import('CloudUploadFile');
     //上傳處理類
     $config = array('allowExts' => array('jpg', 'gif', 'png'), 'savePath' => './' . C("UPLOADPATH") . "ueditor/", 'maxSize' => 11048576, 'saveRule' => 'uniqid');
     $upload = new UploadFile($config);
     $file = $title = $oriName = $state = '0';
     //開始上傳
     if ($upload->upload()) {
         //上傳成功
         $info = $upload->getUploadFileInfo();
         $title = $oriName = $info[0]['name'];
         $state = 'SUCCESS';
         $file = C("TMPL_PARSE_STRING.__UPLOAD__") . "ueditor/" . $info[0]['savename'];
         if (strpos($file, "https") === 0 || strpos($file, "http") === 0) {
         } else {
             //local
             $host = (is_ssl() ? 'https' : 'http') . "://" . $_SERVER['HTTP_HOST'];
             $file = $host . $file;
         }
     } else {
         $state = $upload->getErrorMsg();
     }
     echo "{'url':'" . $file . "','title':'" . $title . "','original':'" . $oriName . "','state':'" . $state . "'}";
 }
開發者ID:Nightchen0521,項目名稱:cmf,代碼行數:25,代碼來源:UeditorAction.class.php

示例13: upload

 public function upload()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = 3145728;
     // 設置附件上傳大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     // 設置附件上傳類型
     $upload->savePath = '__ROOT__/Pic/';
     // 設置附件上傳目錄
     if (!$upload->upload()) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上傳成功 獲取上傳文件信息
         $info = $upload->getUploadFileInfo();
     }
     // 保存表單數據 包括附件數據
     $User = M("User");
     // 實例化User對象
     $User->create();
     // 創建數據對象
     $User->photo = $info[0]['savename'];
     // 保存上傳的照片根據需要自行組裝
     $User->add();
     // 寫入用戶數據到數據庫
     $this->success('數據保存成功!');
 }
開發者ID:ppxj,項目名稱:blsanda,代碼行數:29,代碼來源:PublicAction.class.php

示例14: add

 public function add()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 實例化上傳類
     $upload->maxSize = -1;
     // 設置附件上傳大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     // 設置附件上傳類型
     $upload->savePath = './Public/Uploads/';
     // 設置附件上傳目錄
     if (!$upload->upload()) {
         // 上傳錯誤提示錯誤信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上傳成功 獲取上傳文件信息
         $info = $upload->getUploadFileInfo();
     }
     // 保存表單數據 包括附件數據
     $add = array('username' => $_POST['username'], 'password' => $_POST['password'], 'cname' => $_POST['cname'], 'caddress' => $_POST['caddress'], 'cnature' => $_POST['cnature'], 'cindustry' => $_POST['cindustry'], 'chead' => $_POST['chead'], 'cphone' => $_POST['cphone'], 'email' => $_POST['email'], 'remark' => '1', 'img' => $info[0]['savename'], 'class' => '0');
     if (M('user')->add($add)) {
         $this->success('添加成功', U(GROUP_NAME . '/Login/index'));
     } else {
         $this->error('添加失敗');
     }
 }
開發者ID:omusico,項目名稱:Thinkphp_RMS,代碼行數:26,代碼來源:RegisterAction.class.php

示例15: upload

 public function upload()
 {
     //導入文件上傳的封裝類
     import("ORG.Net.UploadFile");
     //實例化封裝類
     $upload = new UploadFile();
     $upload->maxSize = 10000000;
     //最大上傳文件的大小
     $upload->allowExts = array("jpg", "png", "gif", "rar", "php", "zip");
     //允許上傳文件的擴展名
     $upload->savePath = "public/upfile/";
     //保存路徑
     //上傳
     if ($upload->upload()) {
         //上傳成功
         $arr = $upload->getUploadFileInfo();
         //上傳的文件的相關信息
         print_r($arr);
     } else {
         //上傳失敗
         $msg = $upload->getErrorMsg();
         //獲得上傳的錯誤信息
         $this->success("{$msg}!", "Upload/index");
     }
 }
開發者ID:denson7,項目名稱:phpstudy,代碼行數:25,代碼來源:UploadAction.class.php


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