Exemplo n.º 1
0
 /**
  * Upload image to cloudinary and return the shortened url
  * @param  Image $image 
  * @return string        shortened url
  */
 public function upload($image)
 {
     $this->intConfig();
     if (!is_null($image)) {
         $result = $this->uploader->upload($image);
         $longUrl = $result['url'];
         $this->publicId = $result['public_id'];
         $this->shortUrl = $this->shortenUrl($longUrl);
     }
 }
Exemplo n.º 2
0
 function save($package)
 {
     $Filter = new Filter();
     $name = $this->getName($Filter->get($package, 'name', null));
     if ($Filter->get($package, 'error', false)) {
         // An HTTP error occurred
         return false;
     } else {
         if (empty($name)) {
             // An empty file name was posted
             return false;
         } else {
             if ($this->exists($name)) {
                 return false;
             }
         }
     }
     $Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR));
     list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR);
     if (intval($result) != 1) {
         // The file was not uploaded
         return false;
     }
     if ($this->unzip($tmpfile, $this->directory)) {
         return true;
     }
     unlink($tmpfile);
     return false;
 }
Exemplo n.º 3
0
 function save($package)
 {
     $Filter = new Filter();
     $name = $this->getName($Filter->get($package, 'name', null));
     if ($Filter->get($package, 'error', false)) {
         // An HTTP error occurred
         return false;
     } else {
         if (empty($name)) {
             // An empty file name was posted
             return false;
         } else {
             if ($this->exists($name)) {
                 return false;
             }
         }
     }
     $Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR));
     list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR);
     if (intval($result) != 1) {
         // The file was not uploaded
         return false;
     }
     // handle the file move to the managers dir
     if (!FileSystem::make_dir($this->directory . $name)) {
         // The target directory could not be created
         return false;
     }
     return $this->unzip($tmpfile, $this->directory . $name);
 }
Exemplo n.º 4
0
 public function testUpload()
 {
     $connection = new Connection('http://localhost:5984');
     $uploader = new Uploader($connection);
     $rf = new ResponseFactory();
     $get = new GetDocument($rf);
     $doc = $get->getDocument($connection, 'test', 'doc');
     $uploader->upload('PUT', 'test/' . $doc->_id . '/keya?rev=' . $doc->_rev, 'key');
 }
Exemplo n.º 5
0
 public function createAttachment(Uploader $uploader, $database, $id, $revision, $name, $file)
 {
     $value = $uploader->upload('PUT', $database . '/' . $id . '/' . $name . '?rev=' . $revision, $file);
     $response = $this->response_factory->make($value);
     if ($response->status() !== '201' && $response->status() !== '202') {
         throw new AttachmentCreationException();
     }
     return json_decode($response->body());
 }
Exemplo n.º 6
0
 public function upload($file, $options = array())
 {
     $options['return_error'] = false;
     $ret = Uploader::upload($file, $options);
     $preloaded = new PreloadedFile(Cloudinary::signedPreloadedImage($ret));
     if ($this->verifyUpload && !$preloaded . is_valid()) {
         throw new \Exception("Error! Couldn't verify cloudinary response!");
     }
     $this->identifier = $preloaded->extendedIdentifier();
 }
Exemplo n.º 7
0
 /**
  * Attempt to upload a file via remote import, file system import or standard upload.
  *
  * @access public
  * @param string|array $file
  * @param array $attachment
  * @param array $options
  * @return array
  */
 public function upload($file, $attachment, $options)
 {
     if ($attachment['importFrom']) {
         if (preg_match('/(http|https)/', $attachment['importFrom'])) {
             return $this->uploader->importRemote($attachment['importFrom'], $options);
         } else {
             return $this->uploader->import($attachment['importFrom'], $options);
         }
     }
     return $this->uploader->upload($file, $options);
 }
 public function actionIndex()
 {
     $userId = self::checkAdmin();
     $albums = Category::getCategoryGallery();
     $category = Category::getAdminCategory();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (isset($_POST['data'])) {
             $_SESSION['id_cat'] = $_POST['data'];
         }
         $uploader = new Uploader();
         $data = $uploader->upload($_FILES['file'], array('limit' => 5, 'maxSize' => 10, 'extensions' => null, 'required' => false, 'uploadDir' => 'template/gallery/large/', 'title' => array('name'), 'removeFiles' => true, 'perms' => null, 'onCheck' => null, 'onError' => null, 'onSuccess' => null, 'onUpload' => null, 'onComplete' => null, 'onRemove' => 'onFilesRemoveCallback'));
         $img = new resizeImg('template/gallery/large/' . $_FILES['file']['name']);
         $img->resize(150, 150, 'crop');
         $img->save($_FILES['file']['name']);
         Gallery::saveImgToDB($_FILES['file']['name'], $_SESSION['id_cat']);
     }
     $this->render('admin\\adminUpload', ['title' => 'Загрузка изображений', 'albums' => $albums, 'user' => $userId['email']]);
     return true;
 }
Exemplo n.º 9
0
	List extend
*/
Route::get('admin/extend', array('before' => 'auth', 'main' => function ($page = 1) {
    $vars['messages'] = Notify::read();
    $vars['token'] = Csrf::token();
    return View::create('extend/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
}));
Route::post('admin/get_fields', array('before' => 'auth', 'main' => function () {
    $input = Input::get(array('id', 'pagetype'));
    // get the extended fields
    $vars['fields'] = Extend::fields('page', -1, $input['pagetype']);
    $html = View::create('pages/fields', $vars)->render();
    $token = '<input name="token" type="hidden" value="' . Csrf::token() . '">';
    return Response::json(array('token' => $token, 'html' => $html));
}));
/*
	Upload an image
*/
Route::post('admin/upload', array('before' => 'auth', 'main' => function () {
    $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
    $filepath = $uploader->upload($_FILES['file']);
    $uri = Config::app('url', '/') . 'content/' . basename($filepath);
    $output = array('uri' => $uri);
    return Response::json($output);
}));
/*
	404 error
*/
Route::error('404', function () {
    return Response::error(404);
});
Exemplo n.º 10
0
 public static function upload($file)
 {
     $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
     $filepath = $uploader->upload($file);
     return $filepath;
 }
Exemplo n.º 11
0
     break;
     /* 上传图片 */
 /* 上传图片 */
 case 'uploadimage':
     /* 上传涂鸦 */
 /* 上传涂鸦 */
 case 'uploadscrawl':
     /* 上传视频 */
 /* 上传视频 */
 case 'uploadvideo':
     /* 上传文件 */
 /* 上传文件 */
 case 'uploadfile':
     $policy = array('key' => $_CONFIG['imageFieldName'], 'min_size' => 0, 'max_size' => $_CONFIG['imageMaxSize'], 'file_type' => 'image', 'check_image' => false);
     $up = new Uploader(include "config.inc.php");
     $error = $up->upload($policy);
     if ($error) {
         $result = array('state' => $up->errorMessage($error));
     } else {
         $file = $up->getFile();
         $result = array('state' => 'SUCCESS', 'url' => $file['download_url'], 'title' => $file['fileid'], 'original' => $file['name'], 'type' => "", 'size' => $file['size']);
     }
     break;
     /* 列出图片 */
 /* 列出图片 */
 case 'listimage':
     $result = (include "action_list.php");
     break;
     /* 列出文件 */
 /* 列出文件 */
 case 'listfile':
Exemplo n.º 12
0
<?php

require_once 'upload.class.php';
if (!empty($_FILES)) {
    $uploader = new Uploader();
    $uploader->upload('file_name', '/file_upload/upload.php');
}
Exemplo n.º 13
0
 * Date: 11/7/15
 * Time: 5:24 PM
 */
include_once 'Connection.php';
include_once 'Uploader.php';
include_once 'RSS.php';
if (isset($_POST['submit'])) {
    $title = filter_input(INPUT_POST, 'title');
    $releaseDate = filter_input(INPUT_POST, 'release_date');
    $directorId = filter_input(INPUT_POST, 'director');
    $actorIds = filter_input(INPUT_POST, 'actors', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
    $synopsis = filter_input(INPUT_POST, 'synopsis');
    $return = filter_input(INPUT_POST, 'return');
    $file = $_FILES['upload'];
    $uploader = new Uploader($file);
    $imageLink = $uploader->upload();
    $connection = new Connection();
    $director = $connection->getPeopleById([$directorId]);
    $actors = $connection->getPeopleById($actorIds);
    $view = new Movie(NULL, $director[0], $title, $releaseDate, $synopsis, NULL, $imageLink, $actors);
    $id = $connection->addMovie($view);
    if (!$return) {
        $return = "../index.php";
    }
    $rss = new RSS($id, $title, $id, $synopsis);
    $rss->newRSS();
    if (strpos($return, "?") !== FALSE) {
        $notificationGets = "&addentity={$title}";
    } else {
        $notificationGets = "?addentity={$title}";
    }
Exemplo n.º 14
0
<?php

require __DIR__ . '/../../autoload.php';
$title = $_POST['name'];
$img = $_FILES['image'];
$description = $_POST['description'];
$id = $_POST['id'];
$uploaddir = __DIR__ . "/../../img";
/*upload img*/
$name_file = 'image';
$img = '/../../img/' . $_FILES['image']['name'];
if (!empty($img) && !empty($title) && !empty($description)) {
    $uploads = new Uploader($name_file);
    $uploads->upload($uploaddir);
    $portfolio = new Portfolio();
    $portfolio->updateById($title, $img, $description, $id);
}
header("Location: ../../admin.php");
Exemplo n.º 15
0
<?php

/**
 * Created by PhpStorm.
 * User: Cranky4
 * Date: 13.10.2015
 * Time: 18:04
 */
//стартуем сессию, если ее еще нет
session_start();
include_once "class/Uploader.php";
$uploader = new Uploader();
if ($_FILES && array_key_exists("pic", $_FILES)) {
    $uploader->setMaxSize(2 * 1024 * 1024);
    if ($pathInfo = $uploader->upload($_FILES['pic'])) {
        //сохраняем имя файла в сессию юзера
        $_SESSION['files'][] = $pathInfo['name'];
        //редирект на картинку
        header("Location: /task1/pic.php?path=/uploads/" . $pathInfo['name']);
    } else {
        //вывод ошибок
        print_r($uploader->getErrors());
    }
}
?>

<form method="POST" enctype="multipart/form-data">
    <input type="file" name="pic" required> <input type="submit" value="upload">
</form>

<ul>
if (!isset($filelist)) {
    $filelist = 'filelist.csv';
}
if ($filelist == 'stdin') {
    $handler = @fopen('php://stdin', 'r') or die("Error: No valid fileist data found\n");
} else {
    $handler = @fopen($filelist, 'r') or die("\nError: No valid filelist data found\n");
}
stream_set_blocking($handler, 1);
// Call the class Commons and login in
$wiki = new Uploader();
$wiki->url = $project;
$wiki->setUserAgent('User-Agent: FooBot (http://mediawiki.org/wiki/User:FooBot)');
$wiki->login($user, $password);
while (($data = fgetcsv($handler, 2097152, ";", "'")) !== FALSE) {
    // Get the values from the CSV
    $filename = realpath($data[0]);
    $pagename = $data[1];
    $description = str_replace('\\n', "\n", stripcslashes($data[2]));
    $date = $data[3];
    $source = stripcslashes($data[4]);
    $author = stripcslashes($data[5]);
    $optional = stripcslashes($data[6]);
    $license = stripcslashes($data[7]);
    $categories = stripcslashes($data[8]);
    $categories .= "\n[[Category:Files uploaded with Davod Uploader]]";
    $summary = stripcslashes($data[9]);
    var_dump($wiki->upload($filename, $pagename, $description, $date, $source, $author, $optional, $license, $categories, $summary));
}
fclose($handler);
die;
Exemplo n.º 17
0
 /**
  * 上传文件
  * POST file/upload.json?type={文件解析类型 0文件,1音频,2视频}&basedir={文件夹路径}&redirect={回调地址}
  * FILES
  */
 public function upload()
 {
     header("Access-Control-Allow-Origin: *");
     header("Access-Control-Allow-Credentials: true");
     header("Access-Control-Allow-Methods:POST, GET, PUT, DELETE, OPTIONS");
     header("Access-Control-Allow-Headers:X-FILENAME");
     if (strtolower($_SERVER["REQUEST_METHOD"]) == "options") {
         exit;
     }
     $ctrl_type = intval($_GET['type']);
     $redirect = $_GET['redirect'] ? urldecode($_GET['redirect']) : '';
     $basedir = urldecode($_GET['basedir']);
     if (!$basedir) {
         $basedir = '/home';
     }
     $basedirModel = new Models\FileDirectory();
     if (!$basedirModel->findOne($basedir)) {
         $this->response(ResponseType::FILE_ERROR_DIR_INVALID, '', '', $redirect);
     }
     $uploader = new Uploader();
     $uploader->ctrl_type = $ctrl_type;
     if (!$uploader->upload()) {
         $this->response(ResponseType::FILE_ERROR_UPLOAD, '', '', $redirect);
     }
     //音频文件
     /*
     if($ctrl_type==Uploader::FILETYPE_AUDIO && $uploader->getType() != Uploader::FILETYPE_AUDIO){
     $this->response(ResponseType::FILE_ERROR_AUDIOTYPE,'','',$redirect);
     }
     */
     //文件超过20M
     if ($uploader->getLength() > Core::config('file_max_size')) {
         $this->response(ResponseType::FILE_ERROR_SIZELIMIT, '', '', $redirect);
     }
     if ($fileModel = $basedirModel->makeFile($uploader)) {
         $result['id'] = $fileModel->get_fid();
         $result['src'] = $fileModel->geturi($result['id']);
         $result['mime'] = $fileModel->mime;
         $result['size'] = $fileModel->size;
         $result['name'] = $fileModel->getFilename();
         if ($uploader->getInfo()) {
             $result['meta'] = $uploader->getInfo();
         }
         if ($fileModel->thumb_id) {
             $photoModel = new Models\Photo();
             if ($photoModel->findOne($fileModel->thumb_id, array('width', 'height'))) {
                 $result['thumb']['id'] = $photoModel->get_pid();
                 $result['thumb']['md5'] = $photoModel->md5;
                 $result['thumb']['width'] = $photoModel->width;
                 $result['thumb']['height'] = $photoModel->height;
                 $result['thumb']['mime'] = $photoModel->mime;
                 $imgurls = $photoModel->geturi($fileModel->thumb_id, 130);
                 $result['thumb']['src'] = $imgurls[0];
             }
         }
         $this->response(ResponseType::FILE_OK, '', $result, $redirect);
     } else {
         $this->response(ResponseType::FILE_ERROR_SERVER, '', '', $redirect);
     }
 }
Exemplo n.º 18
0
<?php

include '../src/class.uploader.php';
$uploader = new Uploader();
$data = $uploader->upload('https://www.google.com/images/srpr/logo11w.png', array('uploadDir' => 'uploads/', 'title' => array('auto', 10)));
if ($data['isComplete']) {
    $files = $data['data'];
    print_r($files);
}
if ($data['hasErrors']) {
    $errors = $data['errors'];
    print_r($errors);
}
Exemplo n.º 19
0
 public function upload(&$file, $path = "uploads/", $width = FALSE, $height = FALSE, $ratio = FALSE)
 {
     if ($file["name"]) {
         ini_set("max_execution_time", 600);
         ini_set("memory_limit", "100M");
         $this->filename = uniqid();
         $this->load->library("uploader");
         $handle = new Uploader();
         $handle->upload($file);
         $this->handle =& $handle;
         if ($width) {
             return $this->thumb($path, $width, $height, $ratio);
         } else {
             if (!empty($this->watermark["image"])) {
                 $this->handle->image_watermark = "images/watermark/";
                 $this->handle->image_watermark_position = $this->watermark["position"];
             }
             $this->handle->file_new_name_body = $this->filename;
             $this->handle->process($path);
             if ($this->handle->processed) {
                 return $this->handle->file_dst_name;
             }
         }
     }
 }
Exemplo n.º 20
0
    }
}
if (isset($_FILES['picture'])) {
    FB::log($_POST, 'POST');
    FB::log($_FILES, 'FILES');
    $imagesize = getimagesize($_FILES['picture']['tmp_name']);
    FB::log($imagesize, 'label');
    if (!in_array($_FILES['picture']['type'], array('image/jpeg', 'image/jpg', 'image/pjpeg'))) {
        $error = 'Votre fichier doit être au format jpeg.';
    } elseif ($imagesize[0] / $imagesize[1] != 740 / 340) {
        $error = 'Les dimensions de votre image doivent être de 740x340 ou bien d\'un ratio équivalent.';
    } else {
        require 'classes/uploader.class.php';
        try {
            $upload = new Uploader($_FILES['picture']);
            $upload->setDstPath(getFtpAircraftsRoot() . '/' . $_POST['rep'] . '/');
            $upload->upload();
            $confirm = "L'image " . $_FILES['picture']['name'] . " a été ajoutée";
        } catch (UploaderException $e) {
            $error = $e->getMessage();
        }
    }
}
// Tous les aircrats
$aircrafts = $db->getAllProducts();
foreach ($aircrafts as $aircraft) {
    $aircraft->images = array();
    if (is_dir(getFtpAircraftsRoot() . '/' . $aircraft->rep . '/')) {
        $aircraft->images = readdir_recursive(getFtpAircraftsRoot() . '/' . $aircraft->rep . '/', array('jpg'));
    }
}
Exemplo n.º 21
0
 * Time: 12:17 PM
 */
include_once 'Connection.php';
include_once 'Person.php';
include_once 'Uploader.php';
//TODO eventually check for an auth session token or cookie
if (!isset($_POST['submit'])) {
    header("Location: ../index.php");
    exit;
}
//TODO upload image file and save it to the image repo
$fname = filter_input(INPUT_POST, 'fname');
$lname = filter_input(INPUT_POST, 'lname');
$birthdate = filter_input(INPUT_POST, 'birthdate');
$bio = filter_input(INPUT_POST, 'bio');
$return = filter_input(INPUT_POST, 'return');
$file = $_FILES['upload'];
$uploader = new Uploader($file);
$image_link = $uploader->upload();
$connection = new Connection();
$view = new Person(NULL, $fname, $lname, $birthdate, $image_link, NULL, $bio);
$connection->addPerson($view);
if (!$return) {
    $return = "../index.php";
}
if (strpos($return, "?") !== FALSE) {
    $notificationGets = "&addentity={$fname} {$lname}";
} else {
    $notificationGets = "?addentity={$fname} {$lname}";
}
header("Location: {$return}{$notificationGets}");
Exemplo n.º 22
0
        case 'server':
            return isset($_SERVER[$query]) ? $_SERVER[$query] : $default;
        case 'cookie':
            return isset($_COOKIE[$query]) ? $_COOKIE[$query] : $default;
        default:
            return $default;
    }
}
date_default_timezone_set('PRC');
header('Content-type: application/json');
//上传文件
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (!empty($_FILES)) {
        foreach ($_FILES as $file) {
            $uploader = new Uploader();
            $info = $uploader->upload($file);
            //目前块只包含一个文件
            echo json_encode($uploader->getResult());
            die;
        }
    }
} else {
    if ($_SERVER['REQUEST_METHOD'] === 'GET') {
        //断点上传
        //获取文件基本信息
        $uploader = new Uploader();
        $upload = $uploader->getUploadInfo();
        echo json_encode($upload);
    }
}
/**
Exemplo n.º 23
0
 /**
  * @deprecated Use Uplaoder class
  */
 function UploadFile($file, $dest, $allowtypes, $maxsize = 5000000, $targets = array())
 {
     $Uploader = new Uploader($allowtypes, $targets);
     return $Uploader->upload($file, $dest);
 }
    $wiki = new Uploader($project);
    $login = $wiki->login($user, $password);
    $item = $_POST['item'];
    $pagename = $_POST['pagename'];
    $description = $_POST['description'];
    $date = $_POST['date'];
    $source = $_POST['source'];
    $author = $_POST['author'];
    $optional = $_POST['optional'];
    $license = $_POST['license'];
    $categories = $_POST['categories'];
    $summary = $_POST['summary'];
    foreach ($pagename as $key => $value) {
        $filename = $homepath . $item[$key];
        $pagename_g = $pagename[$key];
        $result[$pagename_g] = $wiki->upload($filename, $pagename_g, $description[$key], $date[$key], $source[$key], $author[$key], $optional[$key], $license[$key], $categories[$key], $summary[$key]);
    }
    $_SESSION['result'] = $result;
    header('Location: ' . $_SERVER['PHP_SELF'] . '?uploaded');
    die;
} elseif (isset($_GET['uploaded'])) {
    if (isset($_SESSION['result'])) {
        $result = $_SESSION['result'];
    } else {
        header('Location: ' . $_SERVER['PHP_SELF']);
        die;
    }
    require_once 'web-header.tpl.php';
    require_once 'web-body-intro.tpl.php';
    require_once 'web-uploaded.tpl.php';
    require_once 'web-footer.tpl.php';
Exemplo n.º 25
0
 public static function unsigned_upload($file, $upload_preset, $options = array())
 {
     return Uploader::upload($file, array_merge($options, array("unsigned" => TRUE, "upload_preset" => $upload_preset)));
 }
Exemplo n.º 26
0
            // 파일에 확장자가 없으면 디렉토리로 판단하여 dir_count를 증가시킴
        } else {
            $file_count++;
            // 파일에 확장자가 있으면 file_count를 증가시킴
        }
    }
    if (!empty($_POST)) {
        // POST가 빈 요청이 아닐때.
        $upload_path = "./upload/";
        // uploader 객체를 생성한다. (라이브러리 직접 수정해도 됨)
        $extentions = array('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png', 'image/gif');
        $uploader = new Uploader(True);
        $uploader->set_extentions($extentions);
        $uploader->set_directory($upload_path);
        $uploader->set_filename("{$file_count}.jpg");
        if ($uploader->upload()) {
        }
    }
    $activation = dietwar_status();
    ?>

<div class="row" style="margin-left: auto; margin-right: auto;">
  <div class="container-fluid col-md-4">
    <h2>다이어트워</h2>
    <form action = "" method = "POST">
     <input type="radio" name="chk_info" value="on" <?php 
    if ($activation[0][0] == 1) {
        echo "checked";
    }
    ?>
> 활성화
Exemplo n.º 27
0
    });
    /*
        Delete post
    */
    Route::get('admin/posts/delete/(:num)', function ($id) {
        Post::find($id)->delete();
        Comment::where('post', '=', $id)->delete();
        Query::table(Base::table('post_meta'))->where('post', '=', $id)->delete();
        Notify::success(__('posts.deleted'));
        return Response::redirect('admin/posts');
    });
    /*
    Upload a image
    */
    Route::post('admin/(pages|posts)/upload', function () {
        $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif'));
        $file = $_FILES['upload'];
        $filepath = $uploader->upload($file);
        //        $uri = Config::app('url', '/') . '/content/' . basename($filepath);
        $uri = '/content/' . basename($filepath);
        $output = array('uploaded' => 1, 'url' => $uri, 'fileName' => $file['name']);
        return Response::json($output);
    });
});
//
//
//{
//	"uploaded": 1,
//    "fileName": "foo.jpg",
//    "url": "/files/foo.jpg"
//}
Exemplo n.º 28
0
    {
        $lowName = strtolower($this->archive["name"]);
        $chars = array("ç", "~", "^", "]", "[", "{", "}", ";", ":", "´", ",", ">", "<", "-", "/", "|", "@", "\$", "%", "ã", "â", "á", "à", "é", "è", "ó", "ò", "+", "=", "*", "&", "(", ")", "!", "#", "?", "`", "ã", " ", "©");
        $newName = str_replace($chars, "", $lowName);
        $this->path = $this->path . "/" . $newName;
    }
    function maxSize()
    {
        if ($this->archive["size"] > 5242880) {
            //Limit: 5MB
            return true;
        }
        return false;
    }
    function extensionVerifier()
    {
        //$temp = stristr($this->archive["name"], ".dbf");
        //echo($this->archive["name"]."-".$temp);
        if (stristr($this->archive["name"], ".dbf")) {
            return true;
        }
        return false;
    }
}
if (!isset($_SESSION["dir"])) {
    header("Location: ../importDocuments.php?dir=erro");
    die;
}
$up = new Uploader($_SESSION["path"]);
$up->upload() ? new Handler($up->tableID, $up->path, $up->folhaType) : header("Location: ../importDocuments.php?upl=false");
Exemplo n.º 29
0
<?php

include 'class.uploader.php';
$uploader = new Uploader();
$data = $uploader->upload($_FILES['files'], array('limit' => 10, 'maxSize' => 10, 'extensions' => null, 'required' => false, 'uploadDir' => '../uploads/', 'title' => array('auto', 10), 'removeFiles' => true, 'perms' => null, 'onCheck' => null, 'onError' => null, 'onSuccess' => null, 'onUpload' => null, 'onComplete' => null, 'onRemove' => 'onFilesRemoveCallback'));
if ($data['isComplete']) {
    $files = $data['data'];
    print_r($files);
}
if ($data['hasErrors']) {
    $errors = $data['errors'];
    print_r($errors);
}
function onFilesRemoveCallback($removed_files)
{
    foreach ($removed_files as $key => $value) {
        $file = '../uploads/' . $value;
        if (file_exists($file)) {
            unlink($file);
        }
    }
    return $removed_files;
}
Exemplo n.º 30
0
 /**
  * 
  * 单步上传接口,分类代码: [0相册照片,1头像照片,2联系人照片,3日记图片,4生活信息图片,5私聊图片]
  * GET upload.json?category={分类id}&redirect={完成后跳转地址}
  * FILES
  */
 public function upload()
 {
     header("Access-Control-Allow-Origin: *");
     header("Access-Control-Allow-Credentials: true");
     header("Access-Control-Allow-Methods:POST, GET, PUT, DELETE, OPTIONS");
     header("Access-Control-Allow-Headers:X-FILENAME");
     if (strtolower($_SERVER["REQUEST_METHOD"]) == "options") {
         exit;
     }
     $cid = intval($_GET['category']);
     $redirect = $_GET['redirect'] ? urldecode($_GET['redirect']) : '';
     $uploader = new Uploader();
     if (!$uploader->upload()) {
         $this->response(ResponseType::PHOTO_UPLOAD_ERROR_INPUT, '', '', $redirect);
     }
     //不是图片类型
     if ($uploader->getType() !== Uploader::FILETYPE_IMAGE) {
         $this->response(ResponseType::PHOTO_ERROR_IMAGETYPE, '', '', $redirect);
     }
     //文件超过5M
     if ($uploader->getLength() > Core::config('photo_max_size')) {
         $this->response(ResponseType::PHOTO_ERROR_IMAGESIZE, '', '', $redirect);
     }
     if ($result = $this->_processUpload($uploader, $cid)) {
         $this->response(ResponseType::PHOTO_UPLOAD_OK, '', $result, $redirect);
     } else {
         $this->response(ResponseType::PHOTO_UPLOAD_ERROR_SERVER, '', '', $redirect);
     }
 }