• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Upload类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Upload的典型用法代码示例。如果您正苦于以下问题:PHP Upload类的具体用法?PHP Upload怎么用?PHP Upload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Upload类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: addUser

 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();
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:26,代码来源:UserController.class.php


示例2: action_index

 /**
  * 首页
  *
  */
 public function action_index()
 {
     if (!empty($_FILES)) {
         $savePath = DOCROOT . 'src_csv/' . $this->auth['uid'] . '/';
         // 保存目录
         $upload = new Upload(array('size' => 10240, 'ext' => array('csv')));
         $upload->set_path($savePath);
         try {
             $result = $upload->save($_FILES['upload_file']);
             $date = array($this->auth['uid'], $this->auth['username'], $result['name'], $result['saveName'], $result['size'], date('Y-m-d H:i:s'));
             $row = DB::insert('imgup_movestore', array('uid', 'uname', 'csv_file', 'src_file', 'freesize', 'upload_time'))->values($date)->execute();
             $content = $this->changeCharacter($savePath . $result['saveName']);
             //preg_match_all("/(src)=[\"|'| ]{0,}((https?\:\/\/.*?)([^>]*[^\.htm]\.(gif|jpg|bmp|png)))/i",$content, $match);
             //preg_match_all("/[\"|'| ]{0,}((https?\:\/\/[a-zA-Z0-9_\.\/]*?)([^<\>]*[^\.htm]\.(gif|jpg|bmp|png)))/i", $content, $match);
             preg_match_all("/\\<img.*?src\\=[\"\\']+[ \t\n]*(https?\\:\\/\\/.*?)[ \t\n]*[\"\\']+[^>]*>/i", $content, $match);
             $imgArr = array_unique($match[1]);
             foreach ($imgArr as $value) {
                 # 去除本站的图片地址
                 if (!preg_match("/^http:\\/\\/[\\w\\.\\-\\_]*wal8\\.com/i", $value)) {
                     DB::insert('store_imgs', array('sid', 'url', 'add_time', 'uid'))->values(array($row[0], $value, time(), $this->auth['uid']))->execute();
                 }
             }
             $link[] = array('text' => '返回', 'href' => '/shopmove');
             $this->show_message('上传' . $result['name'] . '文件成功', 1, $link);
         } catch (Exception $e) {
             $link[] = array('text' => '返回', 'href' => '/shopmove');
             $this->show_message($e->getMessage(), 0, $link);
         }
     }
 }
开发者ID:BGCX261,项目名称:zhongyycode-svn-to-git,代码行数:34,代码来源:shopmove.php


示例3: actionUpload

 /**
  * 编辑器文件上传
  */
 public function actionUpload()
 {
     if (XUtils::method() == 'POST') {
         $file = XUpload::upload($_FILES['imgFile']);
         if (is_array($file)) {
             $model = new Upload();
             $model->user_id = intval($admini['userId']);
             $model->file_name = CHtml::encode($file['pathname']);
             $model->thumb_name = CHtml::encode($file['paththumbname']);
             $model->real_name = CHtml::encode($file['name']);
             $model->file_ext = $file['extension'];
             $model->file_mime = $file['type'];
             $model->file_size = $file['size'];
             $model->save_path = $file['savepath'];
             $model->hash = $file['hash'];
             $model->save_name = $file['savename'];
             $model->create_time = time();
             if ($model->save()) {
                 exit(CJSON::encode(array('error' => 0, 'url' => Yii::app()->baseUrl . '/' . $file['pathname'])));
             } else {
                 @unlink($file['pathname']);
                 @unlink($file['paththumbname']);
                 exit(CJSON::encode(array('error' => 1, 'message' => '上传错误')));
             }
         } else {
             exit(CJSON::encode(array('error' => 1, 'message' => '上传错误:' . $file)));
         }
     }
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:32,代码来源:XUserBase.php


示例4: createquestion

 function createquestion($params, $file_name = '')
 {
     //print_r($_FILES);
     //exit();
     if ($file_name != '') {
         $upload = new Upload($file_name, '../lib/uploads/', 5242880);
         $upload->file_prefix = 'closeup_' . $this->rand_string();
         $upload_result = $upload->upload_process();
         if ($upload->upload_error) {
             $response = $upload->upload_error;
         } else {
             $params['filename'] = $upload_result['name'];
             $fields = array_keys($params);
             $values = $params;
             $tablename = "questions";
             $response = $this->InsertOpt($tablename, $fields, $values);
         }
     } else {
         $fields = array_keys($params);
         $values = $params;
         $tablename = "questions";
         $response = $this->InsertOpt($tablename, $fields, $values);
     }
     return $response;
 }
开发者ID:nimboya,项目名称:SingePageTestEngine,代码行数:25,代码来源:cms.php


示例5: share_validation

 public function share_validation()
 {
     $this->load->library('form_validation');
     $this->load->helper('form');
     $this->form_validation->set_error_delimiters('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>', '</div>');
     //mise en place des regles
     $this->form_validation->set_rules('keywords', 'Mots-clés', 'required|encode_php_tags|htmlspecialchars|trim|xss_clean|max_length[200]');
     $this->form_validation->set_rules('description', 'Description', 'required|encode_php_tags|htmlspecialchars|trim|xss_clean|max_length[300]');
     if ($this->form_validation->run() == FALSE) {
         //on affiche le formulaire
         $this->share();
     } else {
         // upload du fichier
         $file_up = new Upload();
         $user = unserialize($this->session->userdata('user_obj'));
         if ($file_up->upload_file($user->id, array('userfile'))) {
             // Création fichier
             $file = new File();
             $file->id_user = $user->id;
             $file->desc = $this->input->post('description');
             $file->keywords = $this->input->post('keywords');
             $file->url = $file_up->files_uploaded[0][0];
             $file->type = $file_up->files_uploaded[0][1];
             //sauvegarde du fichier
             $file->save();
             //notification
             $this->session->set_userdata('notif_ok', '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Bravo! </strong> Votre partage a été réussi.</div>');
             //redirection sur l'actualité
             redirect('flux', 'refresh');
         } else {
             //on affiche le formulaire
             $this->share();
         }
     }
 }
开发者ID:googlecode-mirror,项目名称:bdm-wavebook-2012,代码行数:35,代码来源:flux.php


示例6: upload

 /**
  * 文件上传
  * @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;
     }
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:39,代码来源:PictureMappingModel.class.php


示例7: hd_uploadify

 /**
  * 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;
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:35,代码来源:ContentUploadController.class.php


示例8: updateImage

        return $this->db->lastInsertId();
    }
    /**
	* Update image
	*/
    public function updateImage($id)
    {
        $ruler = new Ruler($id);
        if ($ruler->Background == null) {
            return false;
        }
        require_once 'core/class.upload/class.upload.php';
        $templates = DIR_DBIMAGES . 'ruler/templates/';
        $results = DIR_DBIMAGES . 'ruler/results/';
        $iu = new Upload($templates . $ruler->Background);
        $iu->file_overwrite = true;
        $iu->file_new_name_body = $id;
        $iu->file_new_name_ext = 'jpg';
        $iu->image_unsharp = true;
        $iu->image_border = '0 0 16 0';
        $iu->image_border_color = strtolower($ruler->Color) == '#ffffff' ? '#333333' : '#ffffff';
        $iu->image_watermark = $templates . $ruler->Slider;
        $iu->image_watermark_y = 35;
        $iu->image_watermark_x = $ruler->getSliderPosition();
        $iu->Process($results);
        $image = imagecreatefromjpeg($results . $id . '.jpg');
开发者ID:AleksandrChukhray,项目名称:good_deals,代码行数:26,代码来源:Ruler.php


示例9: store

 /**
  * Upload the file and store
  * the file path in the DB.
  */
 public function store()
 {
     // Rules
     $rules = array('name' => 'required', 'file' => 'required|max:20000');
     $messages = array('max' => 'Please make sure the file size is not larger then 20MB');
     // Create validation
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $directory = "uploads/files/";
     // Before anything let's make sure a file was uploaded
     if (Input::hasFile('file') && Request::file('file')->isValid()) {
         $current_file = Input::file('file');
         $filename = Auth::id() . '_' . $current_file->getClientOriginalName();
         $current_file->move($directory, $filename);
         $file = new Upload();
         $file->user_id = Auth::id();
         $file->project_id = Input::get('project_id');
         $file->name = Input::get('name');
         $file->path = $directory . $filename;
         $file->save();
         return Redirect::back();
     }
     $upload = new Upload();
     $upload->user_id = Auth::id();
     $upload->project_id = Input::get('project_id');
     $upload->name = Input::get('name');
     $upload->path = $directory . $filename;
     $upload->save();
     return Redirect::back();
 }
开发者ID:pradeep1899,项目名称:ALM_Task_Manager,代码行数:36,代码来源:FilesController.php


示例10: profileActAction

 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');
 }
开发者ID:xinuxZ,项目名称:YOF,代码行数:29,代码来源:Profile.php


示例11: addphotoAction

 public function addphotoAction()
 {
     $db = new Db();
     $this->view->pageHeading = "What are you wearing today?";
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $myform = new Form_Upload();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $myObj = new Upload();
             $Result = $myObj->SaveImage($dataForm);
             if ($Result == 1) {
                 //echo "dsg"; die;
                 $mySession->sucessMsg = "Image saved successfully.";
                 $this->_redirect('post/uploadindex');
             } else {
                 $mySession->errorMsg = "Image you have entered already exists.";
                 $this->view->myform = $myform;
                 $this->render('upload');
             }
         } else {
             $this->view->myform = $myform;
             $this->render('upload');
         }
     } else {
         $this->_redirect('post/upload');
     }
 }
开发者ID:Alexeykolobov,项目名称:php,代码行数:28,代码来源:PostController.php


示例12: hd_uploadify

 /**
  * 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;
 }
开发者ID:jyht,项目名称:v5,代码行数:32,代码来源:ContentUploadControl.class.php


示例13: replace

 public function replace($id = null)
 {
     if (!get('_csrf') or !csrf(get('_csrf'))) {
         return response::error('unauthenticated access');
     }
     $filename = get('filename');
     $file = $this->file($id, $filename);
     $blueprint = blueprint::find($this->page($id));
     $upload = new Upload($file->root(), array('overwrite' => true, 'accept' => function ($upload) use($file) {
         if ($upload->mime() != $file->mime()) {
             throw new Error(l('files.replace.error.type'));
         }
     }));
     if ($file = $upload->file()) {
         try {
             $this->checkUpload($file, $blueprint);
             kirby()->trigger('panel.file.replace', $file);
             return response::success('success');
         } catch (Exception $e) {
             $file->delete();
             return response::error($e->getMessage());
         }
     } else {
         return response::error($upload->error()->getMessage());
     }
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:26,代码来源:files.php


示例14: asignar_cotizacion

 function asignar_cotizacion($id_equipo, $placa_inventario)
 {
     App::import('Vendor', 'upload', array('file' => 'class.upload.php'));
     $this->autoLayout = false;
     $this->autoRender = false;
     $datos_json = array('resultado' => false, 'id' => '', 'nombre_archivo' => '');
     if (!empty($_FILES) && !empty($id_equipo) && !empty($placa_inventario)) {
         if (!empty($_FILES['cotizacion']['name'])) {
             $handle = new Upload($_FILES['cotizacion']);
             if ($handle->uploaded) {
                 $handle->file_overwrite = true;
                 $handle->file_safe_name = false;
                 $handle->file_auto_rename = false;
                 $handle->file_new_name_body = 'cotizacion(' . $this->Cotizacion->getNextAutoIncrement() . ')_' . $placa_inventario;
                 $handle->Process('equipos/cotizaciones');
                 if ($handle->processed) {
                     $this->data['Cotizacion']['nombre_archivo'] = $handle->file_dst_name;
                     $this->data['Cotizacion']['id_equipo'] = $id_equipo;
                     $this->data['Cotizacion']['placa_inventario'] = $placa_inventario;
                     if ($this->Cotizacion->save($this->data)) {
                         $datos_json['resultado'] = true;
                         $datos_json['id'] = $this->Cotizacion->id;
                         $datos_json['nombre_archivo'] = $this->data['Cotizacion']['nombre_archivo'];
                     }
                 }
                 $handle->Clean();
             }
         }
     }
     return json_encode($datos_json);
 }
开发者ID:hongo-de-yuggoth,项目名称:SIMAU,代码行数:31,代码来源:cotizaciones_controller.php


示例15: addHander

 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('文章添加失败');
     }
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:31,代码来源:ArticleController.class.php


示例16: fileupload

/**
 * 文件不是以base64方式上传
 * @param type $path
 * @param type $filename
 * @param type $file
 * @return type
 */
function fileupload($path, $filename, $file)
{
    header("Expires: Mon, 26 Jul 1990 05:00:00");
    //表示永远过期
    header("Last-Modified: " . date("D, d M Y H:i:s"));
    header("Cache-Control: no-store, no-cache, must-revalidate");
    //不使用缓存
    header("Cache-Control: post-check=0, pre-check=0", false);
    //不使用缓存
    header("Pragma: no-cache");
    //不使用缓存
    $upload = new Upload();
    // 实例化上传类
    $upload->rootPath = $path;
    // 设置附件上传根目录
    $upload->savePath = "";
    // 设置附件上传(子)目录
    $var_extend = explode(".", $filename);
    if (count($var_extend) == 1) {
        $upload->saveName = $filename;
    } else {
        $varExt = "." . $var_extend[count($var_extend) - 1];
        $varlength = 0 - strlen($varExt);
        $upload->saveName = substr($filename, 0, $varlength);
    }
    $upload->autoSub = false;
    // 上传文件
    $fileCallback = array("flag" => true, "error" => "", "filename" => $filename);
    $flag = $upload->uploadOne($file);
    if (!$flag) {
        $fileCallback["flag"] = false;
        $fileCallback["error"] = $upload->getError();
    }
    return $fileCallback;
}
开发者ID:yonglinchen,项目名称:shopping,代码行数:42,代码来源:upload.php


示例17: markdown_upload_ajax_image

function markdown_upload_ajax_image()
{
    global $zbp;
    $xhr = array('error' => "", 'url' => "");
    foreach ($_FILES as $key => $value) {
        if ($_FILES[$key]['error'] == 0) {
            if (is_uploaded_file($_FILES[$key]['tmp_name'])) {
                $tmp_name = $_FILES[$key]['tmp_name'];
                $name = $_FILES[$key]['name'];
                $upload = new Upload();
                $upload->Name = $_FILES[$key]['name'];
                $upload->SourceName = $_FILES[$key]['name'];
                $upload->MimeType = $_FILES[$key]['type'];
                $upload->Size = $_FILES[$key]['size'];
                $upload->AuthorID = $zbp->user->ID;
                if (!$upload->CheckExtName()) {
                    $xhr['error'] = $this->lang['error'][26];
                }
                if (!$upload->CheckSize()) {
                    $xhr['error'] = $this->lang['error'][27];
                }
                $upload->SaveFile($_FILES[$key]['tmp_name']);
                $upload->Save();
            }
        }
    }
    if (isset($upload)) {
        CountMemberArray(array($upload->AuthorID), array(0, 0, 0, +1));
        $xhr['url'] = $upload->Url;
    }
    echo json_encode($xhr);
}
开发者ID:zblogcn,项目名称:zblogphp,代码行数:32,代码来源:include.php


示例18: update

 /** загрузка(сохранение/обновление) аватара
  * @param integer ID записи
  * @param boolean удалять предыдущий аватар
  * @return имя файла успешно загруженной аватары | false
  */
 function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false)
 {
     global $oDb;
     if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) {
         $oUpload = new Upload($this->input, false);
         $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']);
         if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             if ($bDeletePrevious) {
                 $this->delete($nRecordID, false);
             }
             $sExtension = func::image_type_to_extension($aImageSize[2], false);
             $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension;
             //проверяем размер файла
             if (!$oUpload->checkSize($this->maxsize)) {
                 return false;
             }
             //создаем thumbnail
             $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']);
             $oThumb->jpeg_quality(85);
             $oThumb->crop_proportionaly(1, 1, 'middle', 'center');
             $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $sFilename, $this->width, $this->height, true);
             @unlink($_FILES[$this->input]['tmp_name']);
             if ($bDoUpdateQuery) {
                 $oDb->execute("UPDATE {$this->table} \n                                   SET {$this->fieldAvatar} =" . $oDb->str2sql($sFilename) . "\n                                   WHERE {$this->fieldID} = {$nRecordID} ");
             }
             return $sFilename;
         }
     }
     return false;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:35,代码来源:avatar.php


示例19: imgUpload

    /**
     * @desc sube una imagen jpg al servidor
     * @param void
     * @return void
     */
    private function imgUpload()
    {
        $msg = "";
        $dir = IMG_LOCAL_PATH . "eventos/" . $this->_event_id;
        $dirweb = IMG_WEB_PATH . "eventos/" . $this->_event_id;
        $handle = new Upload($_FILES['urlfoto']);
        if ($handle->uploaded) {
            // movemos de temp a dir final
            $handle->Process($dir);
            // we check if everything went OK
            if ($handle->processed) {
                // everything was fine !
                $msg .= '!Carga exitosa!: 
	            <a href="' . $dirweb . '/' . $handle->file_dst_name . '">' . $handle->file_dst_name . '</a>';
            } else {
                // one error occured
                $msg .= '<fieldset>';
                $msg .= '  <legend>No es posible mover la imagen en la ruta indicada</legend>';
                $msg .= '  Error: ' . $handle->error . '';
                $msg .= '</fieldset>';
            }
            // we delete the temporary files
            $handle->Clean();
        } else {
            // if we're here, the upload file failed for some reasons
            // i.e. the server didn't receive the file
            $msg .= '<fieldset>';
            $msg .= '  <legend>No es pposible cargar la imagen al servidor.</legend>';
            $msg .= '  Error: ' . $handle->error . '';
            $msg .= '</fieldset>';
        }
        return $msg;
    }
开发者ID:peterweck,项目名称:catman,代码行数:38,代码来源:filebrowser.php


示例20: hd_uploadify

 /**
  * 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;
 }
开发者ID:lililishuang,项目名称:hdcms,代码行数:29,代码来源:ContentUploadController.class.php



注:本文中的Upload类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP UploadBase类代码示例发布时间:2022-05-23
下一篇:
PHP UpgradeHistory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap