Author: Tiny
Inheritance: extends File
 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", 511);
     }
     $firstLetterDir = $_SERVER["DOCUMENT_ROOT"] . "/uploads/" . $firstLetter;
     if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
         mkdir($firstLetterDir, 511);
     }
     if (!file_exists($firstLetterDir . "/" . $this->token) || !is_dir($firstLetterDir . "/" . $this->token)) {
         mkdir($firstLetterDir . "/" . $this->token, 511);
     }
     if (!file_exists($upload->savePath) || !is_dir($upload->savePath)) {
         mkdir($upload->savePath, 511);
     }
     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);
     }
 }
 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("添加不成功");
         }
     }
 }
 public function updataIconSubmit()
 {
     $upload = new UploadFile();
     /* 文件大小单位以字节为单位 */
     $upload->maxSize = C('UPLOAD_ICON_SIZE');
     $upload->allowExts = array('jpg');
     $upload->thumb = true;
     $upload->thumbMaxWidth = '200';
     $upload->thumbMaxHeight = '270';
     $upload->savePath = '../Public/Uploads/icons/';
     if (!$upload->upload()) {
         $info = $upload->getErrorMsg();
         echo '{"data":"' . $info . '","info":"' . $info . '","status":false}';
         /* $this->ajaxReturn ( $info, '更新失败', false ); */
     } else {
         $info = $upload->getUploadFileInfo();
         $m = M('UserBaseinfo');
         $data['icon'] = $info[0]['savename'];
         $result = $m->where('uid="' . $_POST['uid'] . '"')->save($data);
         if ($result) {
             writeOperationLog(APP_NAME, MODULE_NAME, ACTION_NAME, '更新头像');
             echo '{"data":"' . $result . '","info":"Profile updated!","status":true}';
             /* $this->ajaxReturn ( $result, '更新成功', true ); */
         } else {
             echo '{"data":"' . $result . '","info":"Profile update failed!","status":false}';
             /* $this->ajaxReturn ( $result, '更新失败', false ); */
         }
     }
 }
 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;
 }
 public function upimg($path)
 {
     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=false;
     
                 $upload->thumbPrefix        = 'm_,s_';  //生产2张缩略图
                 //设置缩略图最大宽度
                 $upload->thumbMaxWidth      = '620,400';
                 //设置缩略图最大高度
                 $upload->thumbMaxHeight     = '620,400';*/
     //	是否删除原图
     $upload->thumbRemoveOrigin = false;
     //	调用上传方法
     if ($upload->upload()) {
         //	成功则返回对应信息用于之后的调用
         $info = $upload->getUploadFileInfo();
         return $info;
     } else {
         $this->error($upload->getErrorMsg());
     }
 }
 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('失败');
     }
 }
示例#7
0
 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']);
 }
 public function addDoc()
 {
     $course_id = $_POST['course_id'];
     $zhang_name = $_POST['zhang_name'];
     $usertype = Cookie::get('usertype');
     $upload = new UploadFile($_POST['file']);
     $upload->allowExts = array('zip', 'rar', 'gz');
     $upload->savePath = './../Public/Uploads/document/';
     if (!$upload->upload()) {
         $this->error($upload->getErrorMsg());
     } else {
         $info = $upload->getUploadFileInfo();
     }
     $zhang = M('zhang');
     $zhang->create();
     $zhang->course_id = $course_id;
     $zhang->zhang_name = $zhang_name;
     $zhang->file = $info[0]['savename'];
     $result = $zhang->add();
     $this->assign("jumpUrl", "__APP__/Document/teacherindex/id/{$course_id}");
     if ($result) {
         $this->success("添加成功!");
     } else {
         $this->error($result->getErrorMsg());
     }
 }
 /**
  * Upload a File
  *
  * @param upurl - required -
  *          The upload URL.
  * @param bid - required -
  *          The item Id returned in the same call with the upload URL.
  * @param fname - required -
  * 	  		The name of the file to be uploaded. (path+fileName+fileExtension).
  * @return The YsiResponse object containing the upload status.
  * 	 */
 public function uploadaFile($upurl, $bid, $fname)
 {
     $a = new UploadFile($upurl, $bid, $fname);
     $response = $a->sendRequest();
     $response = str_replace("upload-status", "uploadstatus", $response);
     $responseBody = simplexml_load_string($response);
     $returnObject = new YsiResponse();
     if ($responseBody === false) {
         $errorCode = 'N/A';
         $errorMessage = 'The server has encountered an error, please try again.';
         $errorObject = new ErrorStatus($errorCode, $errorMessage);
         $returnObject->setErrorStatus($errorObject);
     } else {
         if (empty($responseBody->errorStatus)) {
             $ufid = (string) $responseBody->ufid;
             $returnObject->setUfid($ufid);
             $uploadStatus = (string) $responseBody->uploadstatus;
             $returnObject->setUploadStatus($uploadStatus);
         } else {
             $errorCode = (string) $responseBody->errorStatus->code;
             $errorMessage = (string) $responseBody->errorStatus->message;
             $errorObject = new ErrorStatus($errorCode, $errorMessage);
             $returnObject->setErrorStatus($errorObject);
         }
     }
     return $returnObject;
 }
 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());
     }
 }
示例#11
0
function upload_image($file)
{
    require_once '../class/upload.class.php';
    $db_img = new DB();
    if (!empty($file)) {
        $time = time();
        $year_month = date('Ym', $time);
        $day = date('d', $time);
        $uploaddir = SHOPPIC_DIR;
        $pic_array = array();
        foreach ($file as $k => $v) {
            $upload = new UploadFile();
            $upload->set('default_dir', $uploaddir);
            $result = $upload->upfile($k);
            if ($result) {
                $sizeinfo = getimagesize($uploaddir . DS . $upload->file_name);
                $pic_array[] = array($upload->file_name, $v['name'], $v['size'], $sizeinfo[0]);
                unset($sizeinfo);
            }
            unset($upload);
        }
        return $pic_array;
    }
    return array();
}
示例#12
0
 function upload()
 {
     $path = str_replace('admin/api/', '', CFG_PATH_ROOT) . 'images/merchants/' . date('ymd', time()) . "/";
     $httpPath = 'images/merchants/' . date('ymd', time()) . "/";
     $thumbnail_path = $path . "thumbnail/";
     require CFG_PATH_ROOT . 'lib/util/UploadFile.class.php';
     require CFG_PATH_ROOT . 'lib/util/Image.class.php';
     $upload = new UploadFile();
     $image = new Image();
     try {
         $filePaths = array();
         if (!is_array($_FILES['upload']['error'])) {
             $filePaths[] = $path . $upload->upload($_FILES['upload'], $path, 1);
         } else {
             foreach ($_FILES['upload']['error'] as $k => $v) {
                 $file["error"] = $_FILES['upload']['error'][$k];
                 $file["name"] = $_FILES['upload']['name'][$k];
                 $file["size"] = $_FILES['upload']['size'][$k];
                 $file["tmp_name"] = $_FILES['upload']['tmp_name'][$k];
                 $file["type"] = $_FILES['upload']['type'][$k];
                 $file_path = $upload->upload($file, $path, 1);
                 //$result = $image->scale($path . $file_path, $thumbnail_path . $file_path, 960, 960);
                 $filePaths[] = $httpPath . $file_path;
             }
         }
         echo $this->json->encode(array("success" => true, "paths" => $filePaths));
         exit;
     } catch (Exception $e) {
         echo $this->json->encode(array('success' => false, 'error' => $e->getMessage()));
         exit;
     }
 }
示例#13
0
 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());
         //专门用来获取上传的错误信息的
     }
 }
示例#14
0
 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);
         }
     }
 }
示例#15
0
 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('更新失败');
     }
 }
示例#16
0
 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']);
     }
 }
示例#17
0
 function changeHead()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     $upload->maxSize = 11048576;
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     $upload->savePath = C("UPLOADPATH");
     $upload->thumb = true;
     $upload->thumbMaxWidth = "120";
     $upload->thumbMaxHeight = "120";
     $upload->thumbRemoveOrigin = true;
     $upload->saveRule = 'uniqid';
     if (!$upload->upload()) {
         $this->error($upload->getErrorMsg(), U('Member/center/index'));
     } else {
         $info = $upload->getUploadFileInfo();
         //添加
         $data = array('_unique' => uniqid(), 'filename' => 'thumb_' . $info[0]['savename'], 'filepath' => C("UPLOADPATH"), 'uploadtime' => time(), 'status' => '1');
         $head_url = '/index.php?g=asset&m=download&key=' . $data['_unique'];
         $memdo = M('Members')->where('ID=' . $_SESSION["MEMBER_id"])->setField('user_pic_url', $head_url);
         //dump($head_url);dump($memdo);
         if (M("Asset")->add($data) && $memdo) {
             $this->success('头像修改成功!');
         } else {
             $this->error('头像修改失败!');
         }
     }
 }
示例#18
0
 /**
  * 上传文件
  * @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);
     }
 }
示例#19
0
 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('添加成功');
     }
 }
示例#20
0
 public function editor_ajax_upload()
 {
     if (!in_array($_GET['upload_dir'], array('group/content', 'merchant/news', 'activity/content', 'system/image', 'activity/index_pic'))) {
         $this->editor_alert('非法的目录!');
     }
     if ($_FILES['imgFile']['error'] != 4) {
         $uid = $_SESSION['merchant']['mer_id'] ? $_SESSION['merchant']['mer_id'] : ($_SESSION['system']['mer_id'] ? $_SESSION['system']['mer_id'] : mt_rand(10000, 99999));
         $img_mer_id = sprintf("%09d", $uid);
         $rand_num = mt_rand(10, 99) . '/' . substr($img_mer_id, 0, 3) . '/' . substr($img_mer_id, 3, 3) . '/' . substr($img_mer_id, 6, 3);
         $upload_dir = './upload/' . $_GET['upload_dir'] . '/' . $rand_num . '/';
         if (!is_dir($upload_dir)) {
             mkdir($upload_dir, 0777, true);
         }
         import('ORG.Net.UploadFile');
         $upload = new UploadFile();
         // $upload->maxSize = $this->config['group_pic_size']*1024*1024;
         $upload->allowExts = array('jpg', 'jpeg', 'png', 'gif');
         $upload->allowTypes = array('image/png', 'image/jpg', 'image/jpeg', 'image/gif');
         $upload->savePath = $upload_dir;
         $upload->thumb = false;
         $upload->saveRule = 'uniqid';
         if ($upload->upload()) {
             $uploadList = $upload->getUploadFileInfo();
             $url = $upload_dir . $uploadList[0]['savename'];
             exit(json_encode(array('error' => 0, 'url' => $url)));
         } else {
             $this->editor_alert($upload->getErrorMsg());
         }
     } else {
         $this->editor_alert('没有选择图片!');
     }
 }
示例#21
0
	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);
        }
	}
示例#22
0
 private function _upload()
 {
     import("@.ORG.Util.UploadFile");
     $module = strtolower($_REQUEST["module"]);
     $upload = new UploadFile();
     $upload->subFolder = $module;
     $upload->savePath = C("SAVE_PATH");
     $upload->saveRule = uniqid;
     $upload->autoSub = true;
     $upload->subType = "date";
     if (!$upload->upload()) {
         $this->error($upload->getErrorMsg());
     } else {
         //取得成功上传的文件信息
         $uploadList = $upload->getUploadFileInfo();
         $File = M("File");
         $File->create($uploadList[0]);
         $File->create_time = time();
         $user_id = get_user_id();
         $File->user_id = $user_id;
         $fileId = $File->add();
         $fileInfo = $uploadList[0];
         $fileInfo['id'] = $fileId;
         $fileInfo['error'] = 0;
         $fileInfo['url'] = $fileInfo['savepath'] . $fileInfo['savename'];
         //header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($fileInfo));
         //$this->success ('上传成功!');
     }
 }
示例#23
0
 protected function _upload()
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //设置上传文件大小
     $upload->maxSize = 3292200;
     //设置上传文件类型
     $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
     //设置附件上传目录
     $upload->savePath = './Public/uploads/Hotel/';
     $upload->saveRule = uniqid;
     $upload->thumb = true;
     $upload->thumbMaxWidth = "300";
     $upload->thumbMaxHeight = "300";
     //删除原图
     //$upload->thumbRemoveOrigin = true;
     if (!$upload->upload()) {
         //捕获上传异常
         $this->error($upload->getErrorMsg());
     } else {
         //取得成功上传的文件信息
         $info = $upload->getUploadFileInfo();
         //dump($info);
         return $info;
     }
 }
示例#24
0
 /**
  * This method prepares the received data and call the addFont method of the fontManager
  * @return boolean true on success
  */
 private function addFont()
 {
     $this->log = "";
     $error = false;
     $files = array("pdf_metric_file", "pdf_font_file");
     foreach ($files as $k) {
         // handle uploaded file
         $uploadFile = new UploadFile($k);
         if (isset($_FILES[$k]) && $uploadFile->confirm_upload()) {
             $uploadFile->final_move(basename($_FILES[$k]['name']));
             $uploadFileNames[$k] = $uploadFile->get_upload_path(basename($_FILES[$k]['name']));
         } else {
             $this->log = translate('ERR_PDF_NO_UPLOAD', "Configurator");
             $error = true;
         }
     }
     if (!$error) {
         require_once 'include/Sugarpdf/FontManager.php';
         $fontManager = new FontManager();
         $error = $fontManager->addFont($uploadFileNames["pdf_font_file"], $uploadFileNames["pdf_metric_file"], $_REQUEST['pdf_embedded'], $_REQUEST['pdf_encoding_table'], array(), htmlspecialchars_decode($_REQUEST['pdf_cidinfo'], ENT_QUOTES), $_REQUEST['pdf_style_list']);
         $this->log .= $fontManager->log;
         if ($error) {
             $this->log .= implode("\n", $fontManager->errors);
         }
     }
     return $error;
 }
 public function upload($allowExts = "jpg,gif,png,jpeg", $savePath = "Upload", $other_param = array())
 {
     class_exists("UploadFile") or import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //  实例化上传类
     $upload->allowExts = explode(",", $allowExts);
     //  设置附件上传类型
     $savePath = $savePath == "/" ? "Upload" : trim($savePath, "/");
     $upload->savePath = ROOT_PATH . "/" . $savePath . "/";
     //  设置附件上传目录
     if (!is_dir($upload->savePath)) {
         mk_dir($upload->savePath);
     }
     $other_key = array("maxSize" => 3145728, "saveRule" => "uniqid", "hashType" => null, "autoCheck" => null, "uploadReplace" => null, "allowTypes" => null, "thumb" => null, "thumbMaxWidth" => null, "thumbMaxHeight" => null, "thumbPrefix" => null, "thumbSuffix" => null, "thumbPath" => null, "thumbFile" => null, "thumbRemoveOrigin" => null, "autoSub" => true, "subType" => "date", "dateFormat" => "Ym", "hashLevel" => 1);
     foreach ($other_key as $key => $val) {
         if (isset($other_param[$key])) {
             $upload->{$key} = $other_param[$key];
         } elseif ($val !== null) {
             $upload->{$key} = $val;
         }
     }
     if (!$upload->upload()) {
         //  上传错误 提示错误信息
         $result = array("status" => false, "Msg" => $upload->getErrorMsg(), "info" => null);
     } else {
         //  上传成功 获取上传文件信息
         $result = array("status" => true, "Msg" => "上传成功", "info" => $upload->getUploadFileInfo());
     }
     return $result;
 }
示例#26
0
 public function change()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 实例化上传类
     $upload->maxSize = -1;
     // 设置附件上传大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     // 设置附件上传类型
     $upload->savePath = './Public/Uploads/img/';
     // 设置附件上传目录
     if (!$upload->upload()) {
         // 上传错误提示错误信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上传成功 获取上传文件信息
         $info = $upload->getUploadFileInfo();
     }
     // 保存表单数据 包括附件数据
     $User = M("user");
     // 实例化User对象
     $data = array('id' => $_SESSION['uid'], 'password' => $_POST['password'], 'img' => $info[0]['savename']);
     //	p($data);die;
     //$User->img = $info[0]['savename']; // 保存上传的照片根据需要自行组装
     $User->save($data);
     // 写入用户数据到数据库
     $this->success('数据保存成功!');
 }
示例#27
0
function upload($data = array(), $savePath, $ext)
{
    foreach ($_FILES as $file) {
        $files = $file['tmp_name'];
        //临时文件
        $info = getimagesize($file['tmp_name']);
        $error = $file['error'];
        if ($error == 1) {
            $data['error'] = "上传限制";
        }
    }
    if ($files) {
        import("ORG.Net.UploadFile");
        $upload = new UploadFile();
        $upload->allowExts = $ext;
        //$upload->maxSize = 2048*100;
        $upload->savePath = $savePath;
        $upload->thumbFile = date('YmdHis', time());
        if (!$upload->upload()) {
            $data['error'] = $upload->getErrorMsg();
        } else {
            $info = $upload->getUploadFileInfo();
            $info[0]['savepath'] = str_replace('.', "", $info[0]['savepath']);
            //转换路径
            $data['upload_url'] = $info[0]['savepath'] . $info[0]['savename'];
            //存储原图
        }
    }
    return $data;
}
示例#28
0
 /**
  * 保存申请
  */
 public function save_deliveryOp()
 {
     if (!chksubmit()) {
         showDialog(L('wrong_argument'));
     }
     $insert = array();
     $insert['dlyp_name'] = $_POST['dname'];
     $insert['dlyp_passwd'] = md5($_POST['dpasswd']);
     $insert['dlyp_truename'] = $_POST['dtruename'];
     $insert['dlyp_mobile'] = $_POST['dmobile'];
     $insert['dlyp_telephony'] = $_POST['dtelephony'];
     $insert['dlyp_address_name'] = $_POST['daddressname'];
     $insert['dlyp_area_2'] = $_POST['area_id_2'];
     $insert['dlyp_area_3'] = $_POST['area_id'];
     $insert['dlyp_area_info'] = $_POST['area_info'];
     $insert['dlyp_address'] = $_POST['daddress'];
     $insert['dlyp_idcard'] = $_POST['didcard'];
     $insert['dlyp_addtime'] = TIMESTAMP;
     $insert['dlyp_state'] = 10;
     $upload = new UploadFile();
     $upload->set('default_dir', ATTACH_DELIVERY);
     $result = $upload->upfile('didcardimg');
     if (!$result) {
         showDialog($upload->error);
     }
     $insert['dlyp_idcard_image'] = $upload->file_name;
     $result = Model('delivery_point')->addDeliveryPoint($insert);
     if ($result) {
         showDialog('操作成功,等待管理员审核', 'index.php?act=login', 'succ');
     } else {
         showDialog(L('nc_common_op_fail'));
     }
 }
示例#29
-1
 public function doMess()
 {
     $message = D('Message');
     $message->create();
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     // 实例化上传类
     $upload->savePath = './Public/Uploads/';
     // 设置附件上传目录
     if (!$upload->upload()) {
         // 上传错误提示错误信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上传成功 获取上传文件信息
         $info = $upload->getUploadFileInfo();
     }
     $message->filename = $info[0]['savename'];
     //$message->time=time();
     //$message->uid=$_SESSION['id'];
     $lastId = $message->add();
     if ($lastId) {
         $this->success('留言成功');
     } else {
         $this->error('留言失败');
     }
 }
示例#30
-1
 protected function upload()
 {
     import('@.ORG.Util.UploadFile');
     $upload = new UploadFile();
     $upload->maxSize = 3145728;
     // 设置附件上传大小
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     // 设置附件上传类型
     $path = 'Data/U/ADS/';
     if (!is_dir($path)) {
         $temp = explode('/', $path);
         $cur_dir = '';
         for ($i = 0; $i < count($temp); $i++) {
             $cur_dir .= $temp[$i] . '/';
             if (!is_dir($cur_dir)) {
                 mkdir($cur_dir, 0777);
             }
         }
     }
     $upload->savePath = $path;
     // 设置附件上传目录
     if (!$upload->upload()) {
         // 上传错误提示错误信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上传成功 获取上传文件信息svnuc\Data\U\ADS
         $info = $upload->getUploadFileInfo();
     }
     return $info;
 }