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


PHP FileUpload::getErrorMsg方法代码示例

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


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

示例1: upload

function upload()
{
    $path = "./uploads/";
    //设置图片上传路径
    $up = new FileUpload($path);
    //创建文件上传类对象
    if ($up->upload('pic')) {
        //上传图片
        $filename = $up->getFileName();
        //获取上传后的图片名
        $img = new Image($path);
        //创建图像处理类对象
        $img->thumb($filename, 300, 300, "");
        //将上传的图片都缩放至在300X300以内
        $img->thumb($filename, 80, 80, "icon_");
        //缩放一个80x80的图标,使用icon_作前缀
        $img->watermark($filename, "logo.gif", 5, "");
        //为上传的图片加上图片水印
        return array(true, $filename);
        //如果成功返回成功状态和图片名称
    } else {
        return array(false, $up->getErrorMsg());
        //如果失败返回失败状态和错误消息
    }
}
开发者ID:EmbededC,项目名称:Community-resource-management,代码行数:25,代码来源:func.inc.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: actionUpload

 public function actionUpload()
 {
     include __DIR__ . "./../uploader/Uploader.php";
     $upload_dir = \Yii::$app->getModule("file")->getStorageDir();
     $uploader = new \FileUpload('uploadfile');
     $fileModel = new File();
     $realName = $_GET["uploadfile"];
     // Handle the upload
     $isUplaoded = $uploader->handleUpload($upload_dir);
     $result = false;
     $errorMsg = '';
     if ($isUplaoded) {
         $fileModel = new File();
         $fileModel->setAttribute("real_name", $realName);
         $fileModel->setAttribute("name_on_server", $uploader->getSavedFileName());
         $fileModel->setAttribute("size", $uploader->getFileSize());
         if (!$fileModel->save()) {
             $uploader->rollBack();
             $errorMsg = "Entity save error";
         } else {
             if (!empty($_GET["relateTo"])) {
                 if (!$fileModel->linkWith($_GET["relateTo"])) {
                     $uploader->rollBack();
                     $fileModel->delete();
                     $errorMsg = "Entity link error";
                 } else {
                     $result = true;
                 }
             } else {
                 $result = true;
             }
         }
     } else {
         $errorMsg = $uploader->getErrorMsg();
     }
     if ($result) {
         echo json_encode(array('success' => true));
     } else {
         exit(json_encode(['success' => false, 'msg' => $errorMsg]));
     }
 }
开发者ID:AsterAI-corp,项目名称:file,代码行数:41,代码来源:StorageController.php

示例4: array

        require '/opt/nginx/html/vendor/upload.php';
        $upload_directory = '/opt/nginx/html/public/uploads/subs';
        $allowed_extensions = array('srt');
        $max_size = 1048576;
        $uploader = new FileUpload('file');
        $ext = $uploader->getExtension();
        if (empty($ext)) {
            $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Invalid file type.'));
            $response->header('Content-Type', 'application/json');
            return $response;
        }
        $filename = uniqid(uniqid(), true) . '.' . $ext;
        $uploader->newFileName = $filename;
        $uploader->sizeLimit = $max_size;
        $result = $uploader->handleUpload($upload_directory, $allowed_extensions);
        $errors = $uploader->getErrorMsg();
        if (!empty($errors)) {
            $response = Response::json(array('result' => false, 'location' => false, 'error' => $uploader->getErrorMsg()));
            $response->header('Content-Type', 'application/json');
            return $response;
        }
        $response = Response::json(array('result' => true, 'type' => 'subs_file', 'data' => URL::to('/uploads/subs') . '/' . $filename));
        $response->header('Content-Type', 'application/json');
        return $response;
    }
});
Route::get('upload', function () {
    if (Auth::guest()) {
    } else {
        return View::make('widgets.upload');
    }
开发者ID:naveengamage,项目名称:okaydrive,代码行数:31,代码来源:routes.php

示例5: FileUpload

}
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'] = "";
    $data['title'] = $_POST['code_title'];
    //$data['content'] = $_POST['code_content'];
    $data['type'] = $_POST['code_type'];
    $data['file_path'] = $file_path_code;
    $data['is_public'] = 1;
    $db->insert('webstyle_code', $data);
}
if (isset($_POST['action']) && $_POST['action'] == 'tempSaveFile') {
    //生成文件
    $File = new FileUtil();
    $File->writetofile(BASE_PATH . 'views/templates/webstyle/temp/' . time() . '.js', $_POST['content']);
开发者ID:ahmatjan,项目名称:manage,代码行数:31,代码来源:add.php

示例6: dirname

<?php

include_once "config.php";
require dirname(__FILE__) . '/Class/Uploader.php';
// Directory where we're storing uploaded images
// Remember to set correct permissions or it won't work
$upload_dir = IMAGEDEVICES;
$valid_extensions = array('gif', 'png', 'jpeg', 'jpg');
$uploader = new FileUpload('uploadfile');
// Handle the upload
$result = $uploader->handleUpload($upload_dir);
if (!$result) {
    exit(json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg())));
}
echo json_encode(array('success' => true));
开发者ID:Basheir,项目名称:AFix,代码行数:15,代码来源:file_upload.php

示例7: FileUpload

<?php

require "FileUpload.class.php";
$up = new FileUpload(array('isRandName' => true, 'allowType' => array('txt', 'doc', 'php', 'gif'), 'FilePath' => './uploads/', 'MAXSIZE' => 200000));
echo '<pre>';
if ($up->uploadFile('spic')) {
    print_r($up->getNewFileName());
} else {
    print_r($up->getErrorMsg());
}
echo '</pre>';
开发者ID:hellowords,项目名称:phptest,代码行数:11,代码来源:upload.php

示例8: explode

                 //手填路径
                 $ordername = '';
             } else {
                 //选择图片提交
                 $picstr = $picurlarr[count($picurlarr) - 1];
                 $picarr = explode('.', $picstr);
                 array_pop($picarr);
                 $ordername = implode('.', $picarr);
             }
         }
     }
     $up = new FileUpload(array('isRandName' => true, 'allowType' => array('swf'), 'FilePath' => $filepath, 'MAXSIZE' => 20 * 1024 * 1024, 'ordername' => $ordername));
     if ($up->uploadFile('flashpic')) {
         $_POST['adv']['flash']['url'] = '/uploadfiles/guanggao/' . $up->getNewFileName();
     } else {
         redirect($up->getErrorMsg(), '-1');
     }
 }
 //zhaoyanmin end
 $code = addslashes(serialize($_POST['adv']));
 !$varname && alert("广告标识符不能为空");
 if ($id) {
     $DreamCMS->db->query("UPDATE `#DC@__advertise` SET `varname` = '{$varname}',`title` = '{$title}',`style`='{$style}',`starttime` = '{$starttime}',`endtime` = '{$endtime}',`code` = '{$code}',`status` = '{$state}' WHERE `id` ='{$id}'");
 } else {
     $DreamCMS->db->query("INSERT INTO `#DC@__advertise`(`varname` , `title` ,`style`, `starttime` , `endtime` , `code` , `status` ) VALUES ('{$varname}','{$title}','{$style}','{$starttime}', '{$endtime}', '{$code}', '{$state}')");
     $id = $DreamCMS->db->insert_id;
 }
 $jsfile = "YWR2ZXJ0aXNl/{$style}-id-{$id}.js";
 $html = getadvhtml($style, stripslashes($code));
 $html = "/*\n{$varname}\n标签:<!--{DreamCMS:advertise name=\"{$varname}\"}-->\n*/\n" . documentwriteln($html);
 writefile(DCPATH . $jsfile, $html);
开发者ID:20000Hz,项目名称:bak-letvs,代码行数:31,代码来源:advertise.inc.php

示例9: array

                            $id = $db->insert_id();
                            echo "<script>alert('视讯信息添加成功,请上传视讯文件?');location.href='../videoadd.php?task=uploadVideoFile&id={$id}';</script>";
                        } else {
                            print_r($up->getErrorMsg());
                            echo "<script>alert('视讯添加失败,是否重试?');location.href='../videoadd.php;</script>";
                        }
                    } else {
                        if (isset($_POST[task]) && "addVideoFile" == $_POST[task]) {
                            //文件保存目录路径
                            $save_path = '../../../video/file/';
                            //定义允许上传的文件扩展名
                            $ext_arr_file = array('swf', 'avi', 'asf', 'mid', 'wmv', 'wma', 'ra');
                            require "FileUpload.class.php";
                            $upFile = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr_file, 'FilePath' => $save_path, 'MAXSIZE' => 200485760));
                            if ($upFile->uploadFile('upfile')) {
                                //print_r($up->getNewFileName());
                                $fname = $upFile->getNewFileName();
                                $sql = "update video set video_path='../video/file/{$fname}' where id = {$_POST['id']}";
                                $db->query($sql);
                                echo "<script>if(confirm('视讯添加完成,是否继续添加?')){location.href='../videoadd.php';}else{location.href='../videolist.php';}</script>";
                            } else {
                                print_r($upFile->getErrorMsg());
                                echo "<script>alert('视讯添加失败,是否重试?');location.href='../videoadd.php';</script>";
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:action.php

示例10: htmlspecialchars

<?php

require 'Uploader.php';
//try to get the directory from the request
$dir = htmlspecialchars($_GET["dir"]);
//if it is null
if ($dir === null || $dir === "") {
    echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
    return;
} else {
    if ($dir === "files") {
        $upload_dir = '././Content/files/';
        //$valid_extensions = array('adi', 'txt', 'cabrillo.txt', 'log', 'cbr');
    } else {
        echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
        return;
    }
}
$Upload = new FileUpload('uploadfile');
$ext = $Upload->getExtension();
// Get the extension of the uploaded file
$time = time();
$Upload->newFileName = $time . '.' . $ext;
//$result = $Upload->handleUpload($upload_dir, $valid_extensions);
$result = $Upload->handleUpload($upload_dir);
if (!$result) {
    echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
} else {
    echo json_encode(array('success' => true, 'file' => $Upload->getFileName(), 'timestamp' => $time));
}
开发者ID:4x6hp,项目名称:IARC,代码行数:30,代码来源:uploadHandler.php

示例11: array

if (isset($_POST[task]) && "LoginADCode" == $_POST[task]) {
    //文件保存目录URL
    $save_path = '../../images/ad/';
    //定义允许上传的文件扩展名
    $ext_arr = array('gif', 'jpg', 'png');
    require "../action/FileUpload.class.php";
    $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 500));
    if ($up->uploadFile('adimage')) {
        $query = $db->query("select type_url,type_code from lm_comm_code where type_name='LoginAdCode' and id='{$_POST['adid']}'");
        $info = $db->fetch_array($query);
        $filename = "images/ad/" . $up->getNewFileName();
        $db->query("update lm_comm_code set type_code='{$filename}',type_url='{$_POST['type_url']}' where type_name='LoginAdCode' and id='{$_POST['adid']}'");
        unlink("../../" . $info[type_code]);
        echo "<script>alert('修改成功!');location.href='../loginad.php';</script>";
    } else {
        printf($up->getErrorMsg());
        $db->query("update lm_comm_code set type_url='{$_POST['type_url']}' where type_name='LoginAdCode' and id='{$_POST['adid']}'");
        echo "<script>alert('图片修改失败或者图片没有修改,广告其他信息修改成功!');location.href='../loginad.php';</script>";
    }
} else {
    if (isset($_POST[task]) && "ADCode" == $_POST[task]) {
        //文件保存目录URL
        $save_path = '../../images/ad/';
        //定义允许上传的文件扩展名
        $ext_arr = array('gif', 'jpg', 'png');
        require "../action/FileUpload.class.php";
        $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 500));
        if ($up->uploadFile('adimage')) {
            $query = $db->query("select type_url,type_code from lm_comm_code where type_name='AdCode' and id='{$_POST['adid']}'");
            $info = $db->fetch_array($query);
            $filename = "images/ad/" . $up->getNewFileName();
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:message.action.php

示例12: FileUpload

 function upload_car($id = 0)
 {
     $this->load->library('FileUpload');
     $upload_dir = 'assets/uploads/cars/';
     $uploader = new FileUpload('uploadfile');
     // Handle the upload
     $result = $uploader->handleUpload($upload_dir);
     if (!$result) {
         exit(json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg())));
     }
     $update = array('img_name' => $uploader->getFileName());
     $this->car_model->update(array('id' => $id), $update);
     echo json_encode(array('success' => true, 'fname' => $uploader->getFileName()));
     exit;
 }
开发者ID:ram-1501,项目名称:rs,代码行数:15,代码来源:dashboard.php

示例13: 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

示例14: array

<?php

require_once 'logincheck.php';
require_once '../library/uploadfile.php';
require_once '../library/excel/reader.php';
$option = array('filepath' => '../upload', 'allowtype' => array('xls'), "maxsize" => "10000000", "israndname" => true);
$file = new FileUpload($option);
if (!$file->uploadFile("uploadfile")) {
    //获取要上传的文件,上传
    $message = $file->getErrorMsg();
} else {
    //插入到数据库中
    $xl = new Spreadsheet_Excel_Reader();
    $xl->setOutputEncoding('CP936');
    $xl->read($option["filepath"] . '/' . iconv("utf-8", "GBK", $file->getNewFileName()));
    $succeed = 0;
    $lost = 0;
    for ($i = 2; $i <= $xl->sheets[0]['numRows']; $i++) {
        $data['STU_NUM'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][1]));
        $data['STU_NAME'] = str_replace(' ', '', iconv("GBK", "utf-8", $xl->sheets[0]['cells'][$i][2]));
        $data['STU_DEP'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][3]));
        $data['STU_PSW'] = $data['STU_NUM'];
        $data['EXAM_YEAR'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][4]));
        if ($db->insert("stuinfo", $data)) {
            $succeed++;
        } else {
            $lost++;
        }
    }
    $message = "成功导入" . $succeed . "条记录,失败" . $lost . "条";
}
开发者ID:dalinhuang,项目名称:dangke,代码行数:31,代码来源:upandinsert.php

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