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


PHP Upload::uploadOne方法代碼示例

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


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

示例1: upload

 public function upload()
 {
     header("Content-Type:text/html;charset=utf-8");
     $upload = new Upload();
     // 實例化上傳類
     $upload->maxSize = 3145728;
     // 設置附件上傳大小(默認3M)
     $upload->exts = array('xls', 'xlsx');
     // 設置附件上傳類
     $upload->savePath = '/';
     // 設置附件上傳目錄
     // 上傳文件
     $parent = $upload->uploadOne($_FILES['parent-file']);
     // 父訂單文件
     $child = $upload->uploadOne($_FILES['child-file']);
     // 子訂單文件
     //        var_dump($info);
     $parentFile = './Uploads' . $parent['savepath'] . $parent['savename'];
     $chileFile = './Uploads' . $child['savepath'] . $child['savename'];
     // 獲取文件後綴名
     $parentExts = $parent['ext'];
     $childExts = $parent['ext'];
     if ($parent && $child) {
         // 上傳成功後導入數據
         $this->import_data($parentFile, $chileFile, $parentExts, $childExts);
         //            sleep(10);
         //            刪除文件
         //            unlink($filename);
     } else {
         //            上傳錯誤提示錯誤信息
         //            $this->error($upload->getError());
         $this->error("上傳文件不完整或沒有文件被上傳!");
     }
 }
開發者ID:Aaron-zh,項目名稱:ThinkPHPFull,代碼行數:34,代碼來源:UploadController.class.php

示例2: myUpdate

 public function myUpdate($data)
 {
     $id = (int) $data['id'];
     unset($data['id']);
     if (empty($data['password'])) {
         unset($data['password']);
     } else {
         $data['password'] = pwd_hash($data['password']);
     }
     if (false === $this->create($data, self::MODEL_UPDATE)) {
         return false;
     }
     //上傳店鋪logo
     if (!empty($data['store_logo'])) {
         $setting = C('PICTURE_UPLOAD');
         $Upload = new Upload($setting);
         $store_logo = $Upload->uploadOne($data['store_logo']);
         if (!$store_logo) {
             $this->error = $Upload->getError();
             return false;
         }
         $store_logo['path'] = substr($setting['rootPath'], 1) . $store_logo['savepath'] . $store_logo['savename'];
         //在模板裏的url路徑
         $this->store_logo = $store_logo['path'];
     } else {
         unset($this->store_logo);
     }
     return $this->where('`id`=' . $id)->save();
 }
開發者ID:hcpzhe,項目名稱:foodorder,代碼行數:29,代碼來源:StoreModel.class.php

示例3: index

 public function index()
 {
     $dir = I('post.dir');
     //獲取
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . '/', 'driver' => '', 'driverConfig' => array());
     //      $config = array(
     //
     //          'rootPath'     => './', //保存到upyun的根路徑
     //          'driver'       => 'Upyun', // 文件上傳驅動
     //          'driverConfig' => array(
     //              'host'     => 'v0.api.upyun.com', //又拍雲服務器
     //              'username' => 'itsource', //又拍操作員用戶
     //              'password' => 'itsource', //又拍雲操作員密碼
     //              'bucket'   => $dir, //空間名稱
     //              'timeout'  => 90, //超時時間
     //          ), // 上傳驅動配置
     //      );
     //實例化對象
     $uploader = new Upload($config);
     //上傳上來的名字
     $result = $uploader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //將上傳後的路徑發送給瀏覽器
         echo $result['savepath'] . $result['savename'];
         //保存路徑和名字  不包含根路徑
     } else {
         echo $uploader->getError();
     }
 }
開發者ID:EasySilent,項目名稱:php1009,代碼行數:29,代碼來源:UploadController.class.php

示例4: uploadOne

 /**
  * 文件上傳
  *
  * @param array $files
  *        	要上傳的文件列表(通常是$_FILES數組)
  * @param array $setting
  *        	文件上傳配置
  * @param string $driver
  *        	上傳驅動名稱
  * @param array $config
  *        	上傳驅動配置
  * @return array 文件上傳成功後的信息
  */
 public function uploadOne($file, $setting, $driver = 'Local', $config = null)
 {
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->uploadOne($file);
     if ($info) {
         // 文件上傳成功,記錄文件信息
         /* 已經存在文件記錄 */
         if (isset($info['id']) && is_numeric($info['id'])) {
             continue;
         }
         /* 記錄文件信息 */
         $info['path'] = $info['savepath'] . $info['savename'];
         // 在模板裏的url路徑
         $value['type'] = 1;
         if ($this->create($info) && ($id = $this->add())) {
             $info['id'] = $id;
         } else {
             // TODO: 文件上傳成功,但是記錄文件信息失敗,需記錄日誌
             unset($info[$key]);
         }
         $this->deleteLocal($file);
         return $info;
         // 文件上傳成功
     } else {
         $this->error = $Upload->getError();
         $this->deleteLocal($file);
         return false;
     }
 }
開發者ID:nullog,項目名稱:zhanglubao,代碼行數:42,代碼來源:DcCoverModel.class.php

示例5: index

 public function index()
 {
     $dir = I('post.dir');
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'doushopdou', 'password' => 'doushopdou', 'bucket' => $dir, 'timeout' => 90));
     $upLoader = new Upload($config);
     $result = $upLoader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         echo $result['savepath'] . $result['savename'];
     } else {
         echo $upLoader->getError();
     }
 }
開發者ID:githublming,項目名稱:1009php,代碼行數:12,代碼來源:UploadController.class.php

示例6: upload2

 public function upload2()
 {
     $file = $_FILES['file'];
     $upload = new \Think\Upload();
     // 實例化上傳類
     $upload->maxSize = 2 * 1024 * 1024;
     $upload->rootPath = './Uploads/';
     // 設置附件上傳根目錄
     $upload->savePath = 'Picture/';
     // 設置附件上傳(子)目錄
     $info = $upload->uploadOne($file);
     exit(json_encode($info));
 }
開發者ID:tearys,項目名稱:lucky,代碼行數:13,代碼來源:IndexController.class.php

示例7: index

 public function index()
 {
     $dir = I('post.dir');
     //echo $dir;
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . "/");
     $upload = new Upload($config);
     $result = $upload->uploadOne($_FILES['Filedata']);
     if ($result) {
         echo $result['savepath'] . $result['savename'];
     } else {
         echo $upload->getError();
     }
 }
開發者ID:zhouliwen,項目名稱:php0110,代碼行數:13,代碼來源:UploadController.class.php

示例8: upload

 public function upload()
 {
     $dir = I('post.dir');
     //如果要將配置放到配置文件中,需要將$dir提出來
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'brazor', 'password' => 'brazorbrazor', 'bucket' => $dir, 'timeout' => 90));
     $upload = new Upload();
     $result = $upload->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         echo $result['savepath'] . $result['savename'];
     } else {
         echo $upload->getError();
     }
 }
開發者ID:ahblin,項目名稱:michael0112,代碼行數:13,代碼來源:UploadController.class.php

示例9: index

 public function index()
 {
     $dir = I('post.dir');
     //獲取瀏覽器指定的服務(空間)
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . '/', 'driverConfig' => array());
     $uploader = new Upload($config);
     $result = $uploader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //將上傳後的路徑發送給瀏覽器
         echo $result['savepath'] . '/' . $result['savename'];
         //保存到upyun上的地址
     }
 }
開發者ID:aa123123,項目名稱:php1009,代碼行數:13,代碼來源:UploadController.class.php

示例10: index

 public function index()
 {
     $dir = I('post.dir');
     $config = C('UPLOAD_CONFIG');
     $config['driverConfig']['bucket'] = $dir;
     $uploader = new Upload($config);
     $rst = $uploader->uploadOne($_FILES['Filedata']);
     if ($rst !== false) {
         echo $rst['savepath'] . $rst['savename'];
     } else {
         echo $uploader->getError();
     }
 }
開發者ID:myservergit,項目名稱:linux_shop,代碼行數:13,代碼來源:UploadController.class.php

示例11: index

 public function index()
 {
     //獲取瀏覽器指定的服務(空間
     $dir = I("post.dir");
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'xluo', 'password' => 'lshaulu0.', 'bucket' => $dir, 'timeout' => 90));
     $upload = new Upload($config);
     $rst = $upload->uploadOne($_FILES['Filedata']);
     if ($rst !== false) {
         echo $rst['savepath'] . $rst['savename'];
     } else {
         $upload->getError();
     }
 }
開發者ID:zaibuxingwojiiugodie,項目名稱:shop,代碼行數:13,代碼來源:UploadController.class.php

示例12: index

 public function index()
 {
     $dir = I('post.dir');
     //上傳配置信息
     $config = array('maxSize' => 0, 'exts' => array(), 'autoSub' => true, 'subName' => array('date', 'Y-m-d'), 'rootPath' => './Uploads/', 'savePath' => $dir . '/', 'saveExt' => '', 'replace' => false, 'callback' => false, 'driver' => '', 'driverConfig' => array());
     $upload = new Upload($config);
     $result = $upload->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //將上傳後的路徑發送給瀏覽器
         echo $result['savepath'] . $result['savename'];
         //保存到的地址
     } else {
         echo $upload->getError();
     }
 }
開發者ID:liunanx,項目名稱:php1009,代碼行數:15,代碼來源:UploadsController.class.php

示例13: index

 public function index()
 {
     //獲取到文件存放的文件夾
     $dir = I('post.dir');
     $config = array('rootPath' => './', 'savePath' => $dir . '/', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'itsource', 'password' => 'itsource', 'bucket' => $dir, 'timeout' => 90));
     $uploader = new Upload($config);
     $result = $uploader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //將上傳後的路徑發送給瀏覽器
         echo $result['savepath'] . $result['savename'];
         //保存到upyun上的地址
     } else {
         echo $uploader->getError();
     }
 }
開發者ID:okjiex,項目名稱:shop,代碼行數:15,代碼來源:UploadController.class.php

示例14: index

 public function index()
 {
     //保存路徑,即根目錄下的文件夾
     $dir = I('post.dir');
     //配置
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'nalanshiwu', 'password' => 'Zwj175370', 'bucket' => $dir, 'timeout' => 90));
     $model = new Upload($config);
     $result = $model->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //保存地址
         echo $result['savepath'] . $result['savename'];
     } else {
         $this->error('上傳失敗' . $model->getError());
     }
 }
開發者ID:zhaowj666,項目名稱:linux_shop,代碼行數:15,代碼來源:UploadController.class.php

示例15: index

 public function index()
 {
     $dir = I('post.dir');
     //從配置中獲得上傳配置
     $config = C('UPLOAD_COF');
     //設置上傳的upyun的服務
     $config['driverConfig']['bucket'] = $dir;
     $upload = new Upload($config);
     $rst = $upload->uploadOne($_FILES['Filedata']);
     if ($rst !== false) {
         echo $rst['savepath'] . $rst['savename'];
     } else {
         echo '上傳失敗:' . $upload->getError();
     }
 }
開發者ID:dower-d,項目名稱:shop,代碼行數:15,代碼來源:UploadController.class.php


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