예제 #1
0
 /**
  * 远程获取图片
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function catchImages()
 {
     $config = ["pathFormat" => Config::get('ueditor::upload.catcherPathFormat'), "maxSize" => Config::get('ueditor::upload.catcherMaxSize'), "allowFiles" => Config::get('ueditor::upload.catcherAllowFiles'), "oriName" => "remote.png"];
     $fieldName = Config::get('ueditor::upload.catcherFieldName');
     /* 抓取远程图片 */
     $list = [];
     if (isset($_POST[$fieldName])) {
         $source = $_POST[$fieldName];
     } else {
         $source = $_GET[$fieldName];
     }
     foreach ($source as $imgUrl) {
         $item = new UeditorUploader($imgUrl, $config, "remote");
         $info = $item->getFileInfo();
         array_push($list, ["state" => $info["state"], "url" => $info["url"], "size" => $info["size"], "title" => htmlspecialchars($info["title"]), "original" => htmlspecialchars($info["original"]), "source" => htmlspecialchars($imgUrl)]);
     }
     /* 返回抓取数据 */
     return Response::json(['state' => count($list) ? 'SUCCESS' : 'ERROR', 'list' => $list]);
 }
예제 #2
0
<?php

/**
 * 抓取远程图片
 * User: Jinqn
 * Date: 14-04-14
 * Time: 下午19:18
 */
set_time_limit(0);
include "UeditorUploader.class.php";
/* 上传配置 */
$config = array("pathFormat" => $CONFIG['catcherPathFormat'], "maxSize" => $CONFIG['catcherMaxSize'], "allowFiles" => $CONFIG['catcherAllowFiles'], "oriName" => "remote.png");
$fieldName = $CONFIG['catcherFieldName'];
/* 抓取远程图片 */
$list = array();
if (isset($_POST[$fieldName])) {
    $source = $_POST[$fieldName];
} else {
    $source = $_GET[$fieldName];
}
foreach ($source as $imgUrl) {
    $item = new UeditorUploader($imgUrl, $config, "remote");
    $info = $item->getFileInfo();
    array_push($list, array("state" => $info["state"], "url" => $info["url"], "size" => $info["size"], "title" => htmlspecialchars($info["title"]), "original" => htmlspecialchars($info["original"]), "source" => htmlspecialchars($imgUrl)));
}
/* 返回抓取数据 */
return json_encode(array('state' => count($list) ? 'SUCCESS' : 'ERROR', 'list' => $list));
예제 #3
0
        break;
    case 'uploadscrawl':
        $config = array("pathFormat" => $CONFIG['scrawlPathFormat'], "maxSize" => $CONFIG['scrawlMaxSize'], "allowFiles" => $CONFIG['scrawlAllowFiles'], "oriName" => "scrawl.png");
        $fieldName = $CONFIG['scrawlFieldName'];
        $base64 = "base64";
        break;
    case 'uploadvideo':
        $config = array("pathFormat" => $CONFIG['videoPathFormat'], "maxSize" => $CONFIG['videoMaxSize'], "allowFiles" => $CONFIG['videoAllowFiles']);
        $fieldName = $CONFIG['videoFieldName'];
        break;
    case 'uploadfile':
    default:
        $config = array("pathFormat" => $CONFIG['filePathFormat'], "maxSize" => $CONFIG['fileMaxSize'], "allowFiles" => $CONFIG['fileAllowFiles']);
        $fieldName = $CONFIG['fileFieldName'];
        break;
}
/* 生成上传实例对象并完成上传 */
$up = new UeditorUploader($fieldName, $config, $base64);
/**
 * 得到上传文件所对应的各个参数,数组结构
 * array(
 *     "state" => "",          //上传状态,上传成功时必须返回"SUCCESS"
 *     "url" => "",            //返回的地址
 *     "title" => "",          //新文件名
 *     "original" => "",       //原始文件名
 *     "type" => ""            //文件类型
 *     "size" => "",           //文件大小
 * )
 */
/* 返回数据 */
return json_encode($up->getFileInfo());