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


PHP Upload::Save方法代码示例

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


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

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

示例2: PostUpload

function PostUpload()
{
    global $zbp;
    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()) {
                    $zbp->ShowError(26);
                }
                if (!$upload->CheckSize()) {
                    $zbp->ShowError(27);
                }
                $upload->SaveFile($_FILES[$key]['tmp_name']);
                $upload->Save();
            }
        }
    }
    if (isset($upload)) {
        CountMemberArray(array($upload->AuthorID));
    }
}
开发者ID:jdjjdkdkdm,项目名称:zblogphp,代码行数:29,代码来源:c_system_event.php

示例3: alert

    // if (empty($ext_arr[$dir_name])) {
    // 	alert("目录名不正确。");
    // }
    //获得文件扩展名
    $temp_arr = explode(".", $file_name);
    $file_ext = array_pop($temp_arr);
    $file_ext = trim($file_ext);
    $file_ext = strtolower($file_ext);
    //检查扩展名
    if (in_array($file_ext, $ext_arr) === false) {
        alert("上传文件扩展名是不允许的扩展名。\n只允许" . implode(",", $ext_arr) . "格式。");
    }
    $upload = new Upload();
    $upload->Name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
    $upload->SourceName = $file_name;
    $upload->MimeType = $_FILES['imgFile']['type'];
    $upload->Size = $file_size;
    $upload->AuthorID = $zbp->user->ID;
    $upload->SaveFile($tmp_name);
    $upload->Save();
    $file_url = $upload->Url;
    header('Content-type: text/html; charset=UTF-8');
    echo json_encode(array('error' => 0, 'url' => $file_url));
    exit;
}
function alert($msg)
{
    header('Content-type: text/html; charset=UTF-8');
    echo json_encode(array('error' => 1, 'message' => $msg));
    exit;
}
开发者ID:zblogcn,项目名称:zblogphp,代码行数:31,代码来源:upload_json.php

示例4: zbp_newMediaObject

function zbp_newMediaObject($xmlstring)
{
    global $zbp;
    $xml = simplexml_load_string($xmlstring);
    if ($xml) {
        $post = array();
        foreach ($xml->children() as $x) {
            $a = (string) $x->name;
            $b = $x->value->children();
            $post[$a] = $b;
        }
        $upload = new Upload();
        $f = GetGuid() . strrchr($post['name'], '.');
        $upload->Name = $f;
        $upload->SourceName = $post['name'];
        $upload->MimeType = $post['type'];
        $upload->Size = 0;
        $upload->AuthorID = $zbp->user->ID;
        $upload->SaveBase64File($post['bits']);
        $upload->Save();
        $strXML = '<methodResponse><params><param><value><struct><member><name>url</name><value><string>$%#1#%$</string></value></member></struct></value></param></params></methodResponse>';
        $strXML = str_replace("\$%#1#%\$", htmlspecialchars($upload->Url), $strXML);
        echo $strXML;
    }
}
开发者ID:jdjjdkdkdm,项目名称:zblogphp,代码行数:25,代码来源:index.php

示例5: saveRemote

 /**
  * 拉取远程图片
  * @return mixed
  */
 private function saveRemote()
 {
     global $zbp;
     $imgUrl = htmlspecialchars($this->fileField);
     $imgUrl = str_replace("&amp;", "&", $imgUrl);
     //http开头验证
     if (strpos($imgUrl, "http") !== 0) {
         $this->stateInfo = $this->getStateInfo("ERROR_HTTP_LINK");
         return;
     }
     //获取请求头并检测死链
     $heads = get_headers($imgUrl, 1);
     if (!(stristr($heads[0], "200") && stristr($heads[0], "OK"))) {
         $this->stateInfo = $this->getStateInfo("ERROR_DEAD_LINK");
         return;
     }
     //格式验证(扩展名验证和Content-Type验证)
     $fileType = strtolower(strrchr($imgUrl, '.'));
     if (!in_array($fileType, $this->config['allowFiles']) || !stristr($heads['Content-Type'], "image")) {
         $this->stateInfo = $this->getStateInfo("ERROR_HTTP_CONTENTTYPE");
         return;
     }
     //打开输出缓冲区并获取远程图片
     ob_start();
     $context = stream_context_create(array('http' => array('follow_location' => false)));
     readfile($imgUrl, false, $context);
     $img = ob_get_contents();
     ob_end_clean();
     preg_match("/[\\/]([^\\/]*)[\\.]?[^\\.\\/]*\$/", $imgUrl, $m);
     $this->oriName = $m ? $m[1] : "";
     $this->fileSize = strlen($img);
     $this->fileType = $this->getFileExt();
     $this->fullName = $this->getFullName();
     $this->filePath = $this->getFilePath();
     $this->fileName = $this->getFileName();
     $dirname = dirname($this->filePath);
     //检查文件大小是否超出限制
     if (!$this->checkSize()) {
         $this->stateInfo = $this->getStateInfo("ERROR_SIZE_EXCEED");
         return;
     }
     $upload = new Upload();
     $upload->Name = $this->fileName;
     $upload->SourceName = $this->fileName;
     $upload->MimeType = $heads['Content-Type'];
     $upload->Size = $this->fileSize;
     $upload->AuthorID = $zbp->user->ID;
     if (!$upload->SaveBase64File(base64_encode($img))) {
         $this->stateInfo = $this->getStateInfo("ERROR_FILE_MOVE");
         return;
     }
     $upload->Save();
     $this->fullName = $upload->Url;
 }
开发者ID:ijustyce,项目名称:zblogphp,代码行数:58,代码来源:Uploader.class.php

示例6: PostUpload

/**
 * 附件上传
 */
function PostUpload()
{
    global $zbp;
    foreach ($_FILES as $key => $value) {
        if ($_FILES[$key]['error'] == 0) {
            if (is_uploaded_file($_FILES[$key]['tmp_name'])) {
                $upload = new Upload();
                $upload->Name = $_FILES[$key]['name'];
                if (GetVars('auto_rename', 'POST') == 'on' || GetVars('auto_rename', 'POST') == true) {
                    $temp_arr = explode(".", $upload->Name);
                    $file_ext = strtolower(trim(array_pop($temp_arr)));
                    $upload->Name = date("YmdHis") . time() . rand(10000, 99999) . '.' . $file_ext;
                }
                $upload->SourceName = $_FILES[$key]['name'];
                $upload->MimeType = $_FILES[$key]['type'];
                $upload->Size = $_FILES[$key]['size'];
                $upload->AuthorID = $zbp->user->ID;
                //检查同月重名
                $d1 = date('Y-m-01', time());
                $d2 = date('Y-m-d', strtotime(date('Y-m-01', time()) . ' +1 month -1 day'));
                $d1 = strtotime($d1);
                $d2 = strtotime($d2);
                $w = array();
                $w[] = array('=', 'ul_Name', $upload->Name);
                $w[] = array('>=', 'ul_PostTime', $d1);
                $w[] = array('<=', 'ul_PostTime', $d2);
                $uploads = $zbp->GetUploadList('*', $w);
                if (count($uploads) > 0) {
                    $zbp->ShowError(28, __FILE__, __LINE__);
                }
                if (!$upload->CheckExtName()) {
                    $zbp->ShowError(26, __FILE__, __LINE__);
                }
                if (!$upload->CheckSize()) {
                    $zbp->ShowError(27, __FILE__, __LINE__);
                }
                $upload->SaveFile($_FILES[$key]['tmp_name']);
                $upload->Save();
            }
        }
    }
    if (isset($upload)) {
        CountMemberArray(array($upload->AuthorID), array(0, 0, 0, +1));
    }
}
开发者ID:zblogcn,项目名称:zblogphp,代码行数:48,代码来源:c_system_event.php


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