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


PHP Upload::getError方法代码示例

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


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

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

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

示例3: uploader

 public function uploader()
 {
     if (!v('user')) {
         message('没有操作权限', 'back', 'error');
     }
     $file = Upload::path(c('upload.path') . '/' . date('Y/m/d'))->make();
     if ($file) {
         $data = ['uid' => v('user.info.uid') ?: v('user.member.uid'), 'siteid' => SITEID, 'name' => $file[0]['name'], 'filename' => $file[0]['filename'], 'path' => $file[0]['path'], 'extension' => strtolower($file[0]['ext']), 'createtime' => time(), 'size' => $file[0]['size'], 'user_type' => v('user.system.user_type'), 'data' => Request::post('data', '')];
         Db::table('core_attachment')->insert($data);
         ajax(['valid' => 1, 'message' => $file[0]['path']]);
     } else {
         ajax(['valid' => 0, 'message' => \Upload::getError()]);
     }
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:14,代码来源:Component.php

示例4: index

 public function index()
 {
     $dir = I('post.dir');
     //获取浏览器指定的服务(空间)
     $config = array('rootPath' => './', '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:wy901216,项目名称:shop,代码行数:15,代码来源:UploadController.class.php

示例5: index

 public function index()
 {
     $dir = I('post.dir');
     //获取浏览器指定的服务
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . '/', 'driver' => '', 'driverConfig' => array());
     $uploader = new Upload($config);
     $result = $uploader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //将上传后的路径发送给浏览器
         echo $result['savepath'] . $result['savename'];
         //保存到upyun上的地址
     } else {
         echo $uploader->getError();
     }
 }
开发者ID:imwork,项目名称:shop,代码行数:15,代码来源:UploadController.class.php

示例6: exeAdd

 function exeAdd()
 {
     $id = (int) Session::get('user')['id'];
     if ($id > 0) {
         $error = '';
         if (!empty($_FILES)) {
             $upload = new Upload('file');
             $upload->setFileExtension('jpg|jepg|png|gif');
             $upload->setUploadDir('public/uploads/members/');
             $upload->setFileSize(2048);
             $e = $upload->getError();
             if (!empty($e)) {
                 foreach ($e as $value) {
                     $error .= $value . '<br />';
                 }
             }
             if ($error != '') {
                 $message = '<div class="album" status="true"><p class="red">' . $error . '</p></div>';
             } else {
                 $imageName = Convert::makeLink($_FILES['file']['name']);
                 $imageLink = $upload->uploads($imageName);
                 $id = $this->model->add(Session::get('user')['username'], $imageName, $imageLink);
                 $message = '<div class="album" imageId="' . $id . '">
                     <img src="' . BASE_URL . '/' . $imageLink . '" alt="' . $imageName . '" class="imgage" />
                     <span class="img-delete" imageId="' . $id . '" title="Xoá ảnh này">X</span>
                     <p>Ngày đăng: ' . date('d-m-Y H:i', time()) . '</p>
                     </div>';
             }
         } else {
             $message = '<div class="album" status="true"><p class="red">Bạn chưa chọn file</p></div>';
         }
         echo $message;
     } else {
         Until::redirectTo();
     }
 }
开发者ID:noikiy,项目名称:lovetolove,代码行数:36,代码来源:Image.php

示例7: explode

        show_error_msg(T_("ERROR"), T_("UPLOAD_NO_PERMISSION"), 1);
    }
    if ($site_config["UPLOADERSONLY"] && $CURUSER["class"] < 4) {
        show_error_msg(T_("ERROR"), T_("UPLOAD_ONLY_FOR_UPLOADERS"), 1);
    }
}
$announce_urls = explode(",", strtolower($site_config["announce_list"]));
//generate announce_urls[] from config.php
if ($_POST["takeupload"] == "yes") {
    require_once "backend/parse.php";
    // Check form data.
    if (!isset($_POST['type'], $_POST['name'])) {
        $message = T_('MISSING_FORM_DATA');
    }
    $tupload = new Upload('torrent');
    if ($num = $tupload->getError()) {
        show_error_msg(T_("UPLOAD"), T_("UPLOAD_ERR[{$num}]"), 1);
    }
    if (!($fname = $tupload->getName())) {
        $message = T_("EMPTY_FILENAME");
    }
    $nfo = 'no';
    if ($_FILES['nfo']['size'] != 0) {
        $nfofile = $_FILES['nfo'];
        if ($nfofile['name'] == '') {
            $message = T_("NO_NFO_UPLOADED");
        }
        if (!preg_match('/^(.+)\\.nfo$/si', $nfofile['name'], $fmatches)) {
            $message = T_("UPLOAD_NOT_NFO");
        }
        if ($nfofile['size'] == 0) {
开发者ID:Fadheler,项目名称:TorrentTrader-3.0,代码行数:31,代码来源:torrents-upload.php

示例8: Upload

    <head>
        <meta charset="UTF-8">
        <title>Helper de gestão de conteúdo</title>
        <link rel="stylesheet" href="css/reset.css" />
    </head>
    <body>
        <?php 
require './_app/Config.inc.php';
$form = filter_input_array(INPUT_POST, FILTER_DEFAULT);
if ($form && $form['SendImage']) {
    $upload = new Upload('uploads/');
    $imagem = $_FILES['image'];
    //            var_dump($imagem);
    $upload->Image($imagem);
    if (!$upload->getResult()) {
        WSErro("Erro ao enviar imágem!<br><small>{$upload->getError()}</small>", WS_ERROR);
    } else {
        WSErro("Imágem enviada com sucesso!<br><small>{$upload->getResult()}</small>", WS_ACCEPT);
    }
    echo '<hr>';
    var_dump($upload);
}
?>

        <form name="fileform" action="" method="post" enctype="multipart/form-data">
            <label>
                <input type="file" name="image"/>
            </label>
            <input type="submit" name="SendImage" value="Enviar arquivo!"/>
        </form>
    </body>
开发者ID:BrunoDuarte,项目名称:WS_PHP_ADMIN,代码行数:31,代码来源:06-helper-de-gestao-de-uploads.php

示例9: microtime

 // 实例化上传类
 $fileName = md5(mt_rand(100, 1000) . microtime(true) . uniqid());
 //文件名
 $upload->maxSize = 3145728;
 // 设置附件上传大小,3M=1024*1024*3
 $upload->exts = array('jpg', 'png', 'jpeg', 'gif');
 // 设置附件上传类型,后缀不区分大小写
 $upload->rootPath = './Uploads/';
 // 设置附件上传根目录
 $upload->subName = array('date', 'Ymd');
 $upload->saveName = $fileName;
 //保持上传文件名不变,如果你想保持上传的文件名不变,那么只需要设置命名规范为空即可,$upload->saveName = '';
 $info = $upload->uploadOne($_FILES['photo']);
 echo '<pre>';
 print_r($info);
 print_r($upload->getError());
 //上传失败错误值,字符串
 //返回值:
 /**
 * Array
     (
        [name] => b.jpg
        [type] => image/jpeg
        [size] => 63172
        [key] => 0
        [ext] => jpg
        [md5] => d78ce021b9b971fa5247d72df7d14b3c
        [sha1] => 490a3bbf53dbb24119e905a9ec470b0f9067f957
        [savename] => 56127e4f0c7fa.jpg
        [savepath] => 20151005/
    )
开发者ID:lyb411,项目名称:util,代码行数:31,代码来源:demo.php

示例10: Read

$resultado = false;
$texto = null;
if (isset($_GET['id'])) {
    $i = $_GET['id'];
    $busca = new Read();
    $busca->ExeRead("extensao", "WHERE id = :id", "id={$i}");
}
if (isset($_POST['titulo'])) {
    $file = $_FILES['extensao'];
    if ($file['name']) {
        //$pdf = substr($busca->getResult()[0]['arquivo'], 0, strrpos($busca->getResult()[0]['arquivo'], '.'));
        //unlink("uploads/{$pdf}");
        $upload = new Upload('uploads/');
        $upload->File($file);
        //se deu errado
        if ($upload->getError()) {
            $texto = $upload->getError();
        } else {
            unlink("uploads/{$busca->getResult()[0]['arquivo']}");
            $dados = ['titulo' => $_POST['titulo'], 'resumo' => $_POST['resumo'], 'ano' => $_POST['ano'], 'autores' => $_POST['autores'], 'coordenador' => $_POST['coordenador'], 'unidadeExecutora' => $_POST['unidadeExecutora'], 'area' => $_POST['area'], 'dataInicio' => $_POST['dataInicio'], 'dataTermino' => $_POST['dataTermino'], 'arquivo' => $upload->getResult()];
            $update = new Update();
            $update->ExeUpdate('extensao', $dados, "WHERE id = :id", "id={$i}");
            if ($update->getResult()) {
                $resultado = true;
                //echo "{$update->getRowCount()} dados atualizados com sucesso! <hr>";
                $busca->ExeRead("extensao", "WHERE id = :id", "id={$i}");
            }
        }
    } else {
        $dados = ['titulo' => $_POST['titulo'], 'resumo' => $_POST['resumo'], 'ano' => $_POST['ano'], 'autores' => $_POST['autores'], 'coordenador' => $_POST['coordenador'], 'unidadeExecutora' => $_POST['unidadeExecutora'], 'area' => $_POST['area'], 'dataInicio' => $_POST['dataInicio'], 'dataTermino' => $_POST['dataTermino']];
        $update = new Update();
开发者ID:brenolessa,项目名称:projeto-RI-Br,代码行数:31,代码来源:editarExtensao.php

示例11: Upload

switch ($method) {
    case "GET":
        //retorno não implementado
        echo json_encode($request);
        break;
    case "POST":
        //Adiciona arquivo a pasta temporaria
        if (!empty($_FILES['files'])) {
            $gbFiles = Check::ListFiles($_FILES['files']);
            $Upload = new Upload();
            $RESP = array();
            $i = 0;
            foreach ($gbFiles as $File) {
                $Upload->File($File, null, 'temp', 50);
                if ($Upload->getError() && stripos($Upload->getError(), 'image')) {
                    $Upload->Image($File, null, null, 'temp');
                }
                $File['tmp_name'] = BASEDIR . '/uploads/' . $Upload->getResult();
                $RESP[$i]['RESULT'] = HOME . '/uploads/' . $Upload->getResult();
                $RESP[$i]['TYNY'] = HOME . "/tim.php?src=" . $RESP[$i]['RESULT'] . "&w=202&h=105";
                $RESP[$i]['URL'] = $Upload->getResult();
                $RESP[$i]['ERROS'] = $Upload->getError();
                $RESP[$i]['FILE'] = $File;
                $i++;
            }
            if ($Upload->getResult()) {
                echo json_encode($RESP);
            } else {
                echo $Upload->getError();
            }
开发者ID:adrianosilvareis,项目名称:intranet,代码行数:30,代码来源:upload.api.php

示例12: exeChangeAvatar

 function exeChangeAvatar()
 {
     $id = (int) Session::get('user')['id'];
     if ($id > 0) {
         $error = '';
         if (!empty($_FILES)) {
             $upload = new Upload('file');
             $upload->setFileExtension('jpg|jepg|png|gif');
             $upload->setUploadDir('public/uploads/avatar/');
             $upload->setFileSize(1024);
             $e = $upload->getError();
             if (!empty($e)) {
                 foreach ($e as $value) {
                     $error .= $value . '<br />';
                 }
             }
             if ($error != '') {
                 $message = '<p class="red">' . $error . '</p>';
             } else {
                 $imageName = Convert::makeLink($_FILES['file']['name']);
                 $imageLink = $upload->uploads($imageName);
                 $this->model->changeAvatar(Session::get('user')['id'], $imageLink);
                 if (Session::get('user')['avatar'] != 'public/uploads/members/member-1.png' || Session::get('user')['avatar'] != 'public/uploads/members/member-1.png') {
                     if (file_exists(Session::get('user')['avatar'])) {
                         unlink(Session::get('user')['avatar']);
                     }
                 }
                 $data = Session::get('user');
                 $data['avatar'] = $imageLink;
                 Session::set('user', $data);
                 $message = '1';
             }
         } else {
             $message = '<p class="red">Bạn chưa chọn file</p>';
         }
         echo $message;
     } else {
         Until::redirectTo();
     }
 }
开发者ID:noikiy,项目名称:lovetolove,代码行数:40,代码来源:User.php

示例13: UpdateImage

 private function UpdateImage()
 {
     if (is_array($this->Data['post_cover'])) {
         $WsPosts = new WsPosts();
         $WsPosts->setPost_id($this->Post);
         $WsPosts->Execute()->find();
         $this->deletaImagem('../uploads/' . $WsPosts->Execute()->getResult()->post_cover);
         $upload = new Upload();
         $upload->Image($this->Data['post_cover'], $this->Data['post_name']);
     }
     if (isset($upload) && $upload->getResult()) {
         $this->Data['post_cover'] = $upload->getResult();
         $this->Update();
     } else {
         unset($this->Data['post_cover']);
         if (!empty($upload) && $upload->getError()) {
             WSErro("<b>ERRO AO ENVIAR CAPA: </b>" . $upload->getError(), E_USER_WARNING);
         }
         $this->Update();
     }
 }
开发者ID:adrianosilvareis,项目名称:OutlineTecnolog,代码行数:21,代码来源:AdminPost.class.php

示例14: exeInsert

 public function exeInsert()
 {
     if (isset($_POST['submit'])) {
         $file = false;
         $service = (int) Request::post('services');
         $title = Request::post('title');
         $content = Request::post('content');
         $author = Session::get('user')['username'];
         $quote = Request::post('quote');
         $pin = (int) Request::post('pin');
         $error = '';
         if ($title == null) {
             $error .= 'Tên bài viết không được trống.<br />';
         }
         if ($quote == null) {
             $error .= 'Trích dẫn không được trống.<br />';
         }
         if ($content == null) {
             $error .= 'Nội dung không được trống.<br />';
         }
         if ($_FILES['file']['tmp_name'] != null) {
             $upload = new Upload('file');
             $upload->setFileExtension('jpg|jepg|png|gif');
             $upload->setUploadDir('public/uploads/articles/');
             $upload->setFileSize(1024);
             $e = $upload->getError();
             if (!empty($e)) {
                 foreach ($e as $value) {
                     $error .= $value . '<br />';
                 }
             }
             $file = true;
         }
         if ($error != '') {
             Session::set('article', $_POST);
             Session::set('error', $error);
             Until::redirectTo('article/add');
         } else {
             $imageName = '';
             $imageLink = '';
             if ($file) {
                 $imageName = Convert::makeLink($title);
                 $imageLink = $upload->uploads($imageName);
             }
             $id = $this->model->add($service, $title, $content, $author, $quote, $imageName, $imageLink, $pin);
             Until::redirectTo('article/detail?id=' . $id);
         }
     } else {
         Until::redirectTo();
     }
 }
开发者ID:noikiy,项目名称:lovetolove,代码行数:51,代码来源:Article.php

示例15: sendCapa

 private function sendCapa()
 {
     if (!empty($this->Data['empresa_capa']['tmp_name'])) {
         list($w, $h) = getimagesize($this->Data['empresa_capa']['tmp_name']);
         if ($w != '578' || $h != '288') {
             $_SESSION['errCapa'] = ['Capa Inválida: A Capa da empresa deve ter exatamente 578x288px do tipo .JPG, .PNG ou .GIF!', WS_INFOR];
             $this->Result = false;
             $this->Data['empresa_capa'] = null;
         } else {
             $this->checkCover();
             $Upload = new Upload();
             $Upload->Image($this->Data['empresa_capa'], $this->Data['empresa_name'], 578, 'empresas');
             if ($Upload->getError()) {
                 $this->Error = $Upload->getError();
                 $this->Result = false;
             } else {
                 $this->Data['empresa_capa'] = $Upload->getResult();
                 $this->Result = true;
             }
         }
     }
 }
开发者ID:adrianosilvareis,项目名称:FrameWork_Front,代码行数:22,代码来源:AdminEmpresa.class.php


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