当前位置: 首页>>代码示例>>PHP>>正文


PHP FileUpload::set方法代码示例

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


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

示例1: preform

 public function preform()
 {
     $uploadFile = new FileUpload();
     $uploadFile->set("path", "./images/");
     $uploadFile->set("maxsize", 2000000);
     $uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $uploadFile->set("israndname", false);
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:8,代码来源:AddArticleModel.class.php

示例2: preform

 public function preform()
 {
     $uploadFile = new FileUpload();
     $uploadFile->set("maxsize", 2000000);
     $uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $uploadFile->set("israndname", true);
     if ($this->params['safe']['type'] == "addArticle") {
         $path = "../uploadfile/article/" . $this->params['safe']['fenlei_id'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fm_img')) {
             $data = array('uid' => 1, 'title' => $this->params['safe']['title'], 'contents' => $this->params['safe']['contents'], 'fenlei_id' => $this->params['safe']['fenlei_id'], 'fm_img' => $path . $uploadFile->getFileName(), 'time' => time());
             $DaoArticle = new DaoArticle();
             $DaoArticle->insertArticle($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addUser") {
         $path = "../uploadfile/user_img/" . $this->params['safe']['user_name'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('user_img')) {
             $data = array('user_name' => $this->params['safe']['user_name'], 'user_nickname' => $this->params['safe']['user_nickname'], 'user_password' => md5($this->params['safe']['password']), 'user_qm' => "这家伙还没写签名呢!", 'user_img' => $path . $uploadFile->getFileName(), 'user_inTime' => time());
             $DaoUser = new DaoUser();
             $DaoUser->addUser($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addfenlei") {
         $path = "../uploadfile/Fenlei/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fenlei_img')) {
             $data = array('name' => $this->params['safe']['name'], 'time' => time(), 'fenlei_img' => $path . $uploadFile->getFileName());
             $DaoFenlei = new DaoFenlei();
             $DaoFenlei->addFenlei($data);
         }
     }
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:38,代码来源:DoModel.class.php

示例3: createFile

include $_SERVER['DOCUMENT_ROOT'] . $folder_name . '/config.inc.php';
//引入文件操作类
require '../public/FileUtil.php';
//引入文件上传类
require '../public/fileUpload.class.php';
function createFile($title, $type, $content)
{
    //生成文件
    $File = new FileUtil();
    $File->writetofile(BASE_PATH . 'upload/webstyle/public/' . $type . '/' . $title . '.' . $type, $content);
    return $codeFilePath = '/manage/upload/webstyle/public/' . $type . '/' . $title . '.' . $type;
}
if (isset($_POST['category']) && $_POST['category'] == 'code') {
    $up = new FileUpload();
    //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
    $up->set("path", "../../upload/webstyle/public/" . $_POST['code_type']);
    $up->set("maxsize", 2000000);
    $up->set("allowtype", array("gif", "png", "jpg", "jpeg", 'css', 'js'));
    $up->set("israndname", false);
    //使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
    if ($up->upload("file")) {
        var_dump($up->getFileName());
        $file_path_code = '/manage/upload/webstyle/public/' . $_POST['code_type'] . '/' . $up->getFileName();
    } else {
        echo '<pre>';
        //获取上传失败以后的错误提示
        var_dump($up->getErrorMsg());
        echo '</pre>';
    }
    $db = new DB();
    $data['id'] = "";
开发者ID:ahmatjan,项目名称:manage,代码行数:31,代码来源:add.php

示例4: upload

 function upload($path = '')
 {
     $path = trim($path, '/');
     $folder = $this->BasePath . $path;
     if (!is_dir($folder)) {
         if (is_gb2312($path)) {
             $path = iconv('gb2312', 'utf-8', $path);
         }
         throw new Exception("文件夹 '{$path}' 不存在。");
     }
     if (!file_exists('fileupload.class.php')) {
         throw new Exception("没找到文件'fileupload.class.php, 无法上传文件。");
     }
     require_once 'fileupload.class.php';
     $up = new FileUpload();
     //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
     $up->set("path", $folder);
     $up->set("maxsize", 8 * 1024 * 1024);
     if (empty($this->allowType) || $this->allowType == '*') {
         $up->set("allowtype", explode(',', $this->allType));
     } else {
         $up->set("allowtype", explode(',', $this->allowType));
     }
     $up->set("israndname", false);
     if (!$up->upload("file")) {
         $errors = $up->getErrorMsg();
         if (is_array($errors)) {
             $errors = implode("\n", $errors);
         }
         throw new Exception($errors);
     } else {
         $filenames = $up->getFileName();
         if (is_string($filenames)) {
             $filenames[] = $filenames;
         }
         foreach ($filenames as $key => $value) {
             $filename = iconv('utf-8', 'gb2312', $value);
             if (true === @rename($folder . '/' . $value, $folder . '/' . $filename)) {
                 $filenames[$key] = $filename;
             }
         }
     }
     return $up->getFileName();
 }
开发者ID:steven-ye,项目名称:YesFinder,代码行数:44,代码来源:YesFinder.class.php

示例5: upload

 function upload($path = '')
 {
     $path = $this->BaseUrl . '/' . trim($path, '/');
     if (!is_dir($path)) {
         $data['error'] = 'Folder ' . $path . ' does not exist.';
         return $data;
     }
     $up = new FileUpload();
     //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
     $up->set("path", $path);
     $up->set("maxsize", 8 * 1024 * 1024);
     if (!empty($this->allowType) && $this->allowType != '*') {
         $up->set("allowtype", explode(',', $this->allowType));
     }
     $up->set("israndname", false);
     if ($up->upload("upfile")) {
         return $up->getFileName();
     } else {
         $data['error'] = $up->getErrorMsg();
     }
     /**/
     return $data;
 }
开发者ID:steven-ye,项目名称:YesFinder,代码行数:23,代码来源:yesfinder.class.php


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