コード例 #1
1
ファイル: document.php プロジェクト: kosmosby/medicine-prof
 public function uploader()
 {
     error_reporting(0);
     JLoader::register('PluploadHandler', JPATH_SITE . '/components/com_judownload/helpers/pluploadhandler.php');
     $targetDir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/") . "tmp";
     $cleanupTargetDir = true;
     $maxFileAge = 5 * 3600;
     $this->cleanup($targetDir, $maxFileAge);
     if (!JFolder::exists($targetDir)) {
         JFolder::create($targetDir);
         $indexHtml = $targetDir . 'index.html';
         $buffer = "<!DOCTYPE html><title></title>";
         JFile::write($indexHtml, $buffer);
     }
     if (!is_writable($targetDir)) {
         $targetDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "plupload";
         if (!file_exists($targetDir)) {
             @mkdir($targetDir);
         }
     }
     PluploadHandler::no_cache_headers();
     PluploadHandler::cors_headers();
     if (!PluploadHandler::handle(array('target_dir' => $targetDir, 'cleanup' => $cleanupTargetDir, 'max_file_age' => $maxFileAge, 'cb_check_file' => array(__CLASS__, 'canUpload')))) {
         die(json_encode(array('OK' => 0, 'error' => array('code' => PluploadHandler::get_error_code(), 'message' => PluploadHandler::get_error_message()))));
     } else {
         die(json_encode(array('OK' => 1)));
     }
 }
コード例 #2
0
ファイル: functions_ajax.php プロジェクト: alenteria/WeBid
function upload_images()
{
    global $user, $MSG;
    if (!$user->logged_in) {
        // imitate code execution
        die(json_encode(array('OK' => 0, 'error' => array('code' => '202', 'message' => $MSG['login_required_text']))));
    } else {
        global $main_path, $upload_path, $include_path;
        require_once $include_path . "PluploadHandler.php";
        $uploader = new PluploadHandler();
        $uploader->no_cache_headers();
        $uploader->cors_headers();
        $targetDir = $upload_path . session_id();
        if (!$uploader->handle(array('target_dir' => $targetDir, 'allow_extensions' => 'jpg,jpeg,png,gif'))) {
            die(json_encode(array('OK' => 0, 'error' => array('code' => $uploader->get_error_code(), 'message' => $uploader->get_error_message()))));
        } else {
            //upload was good
            $conf = $uploader->get_conf();
            $fileName = $conf['file_name'];
            if (!in_array($fileName, $_SESSION['UPLOADED_PICTURES'])) {
                $final_file_name = strtolower($fileName);
                array_push($_SESSION['UPLOADED_PICTURES'], $final_file_name);
                if (count($_SESSION['UPLOADED_PICTURES']) == 1) {
                    $_SESSION['SELL_pict_url_temp'] = $_SESSION['SELL_pict_url'] = $final_file_name;
                }
            }
            die(json_encode(array('OK' => 1)));
        }
    }
}
コード例 #3
0
ファイル: functions_ajax.php プロジェクト: Nozlaf/WeBid
function upload_images()
{
    global $user, $MSG, $system;
    if (!$user->logged_in) {
        // imitate code execution
        die(json_encode(array('OK' => 0, 'error' => array('code' => '202', 'message' => $MSG['login_required_text']))));
    } else {
        require_once PACKAGE_PATH . 'PluploadHandler.php';
        $uploader = new PluploadHandler();
        $uploader->no_cache_headers();
        $uploader->cors_headers();
        $targetDir = UPLOAD_PATH . session_id();
        if (!$uploader->handle(array('target_dir' => $targetDir, 'allow_extensions' => 'jpg,jpeg,png,gif'))) {
            die(json_encode(array('OK' => 0, 'error' => array('code' => $uploader->get_error_code(), 'message' => $uploader->get_error_message()))));
        } else {
            //upload was good
            $conf = $uploader->get_conf();
            $fileName = $conf['file_name'];
            // resize picture
            $uploader->resizeThumbnailImage($targetDir . '/' . $fileName, $system->SETTINGS['gallery_max_width_height']);
            $final_file_name = strtolower($fileName);
            if (!in_array($final_file_name, $_SESSION['UPLOADED_PICTURES'])) {
                array_push($_SESSION['UPLOADED_PICTURES'], $final_file_name);
                if (count($_SESSION['UPLOADED_PICTURES']) == 1) {
                    $_SESSION['SELL_pict_url_temp'] = $_SESSION['SELL_pict_url'] = $final_file_name;
                }
            }
            die(json_encode(array('OK' => 1)));
        }
    }
}
コード例 #4
0
/**
 * Handle ajax chunked file uploads.
 */
function humcore_upload_handler()
{
    global $fedora_api;
    require_once dirname(__FILE__) . '/PluploadHandler.php';
    PluploadHandler::no_cache_headers();
    PluploadHandler::cors_headers();
    $upload_status = PluploadHandler::handle(array('target_dir' => $fedora_api->tempDir . '/', 'allow_extensions' => 'csv,doc,docx,f4v,flv,gif,gz,htm,html,jpeg,jpg,mov,mp3,mp4,odp,ods,odt,ogg,pdf,png,ppt,pptx,pps,psd,rdf,rtf,sxc,sxi,sxw,tar,tiff,txt,tsv,wav,wpd,xls,xlsx,xml,zip'));
    if (!$upload_status) {
        die(json_encode(array('OK' => 0, 'error' => array('code' => PluploadHandler::get_error_code(), 'message' => PluploadHandler::get_error_message()))));
    } else {
        die(json_encode(array('OK' => 1)));
    }
}
コード例 #5
0
ファイル: Core.class.php プロジェクト: im286er/iBarn
 public function upload()
 {
     if (!$_REQUEST['uid']) {
         echo Response::json(LACK, array(tip('用户ID不能为空')));
         exit;
     }
     $_REQUEST['name'] = self::filterName(rawurldecode(self::trimSpace($_REQUEST['name'])));
     if (!$_REQUEST['name']) {
         echo Response::json(LACK, array(tip('文件名不能为空')));
         exit;
     }
     if (!$_REQUEST['type']) {
         if (!file_exists(DATA_DIR)) {
             $res = mkdir(DATA_DIR, 0777, true);
             if (!$res) {
                 echo Response::json(FAIL, array(tip('存储目录创建失败')));
                 exit;
             }
         }
     }
     if (!file_exists(UP_DIR)) {
         $res = mkdir(UP_DIR, 0777, true);
         if (!$res) {
             echo Response::json(FAIL, array(tip('存储目录创建失败')));
             exit;
         }
     }
     include LIB_PATH . 'plupload' . DS . 'PluploadHandler.php';
     PluploadHandler::no_cache_headers();
     PluploadHandler::cors_headers();
     if (!PluploadHandler::handle(array('target_dir' => UP_DIR))) {
         echo Response::json(FAIL, array(tip('上传失败')));
         exit;
     } else {
         echo Response::json(SUCC, array(tip('上传成功')));
     }
 }
コード例 #6
0
<?php

require_once "PluploadHandler.php";
PluploadHandler::no_cache_headers();
PluploadHandler::cors_headers();
if (!PluploadHandler::handle(array('target_dir' => 'uploads/', 'allow_extensions' => 'jpg,jpeg,png'))) {
    die(json_encode(array('OK' => 0, 'error' => array('code' => PluploadHandler::get_error_code(), 'message' => PluploadHandler::get_error_message()))));
} else {
    die(json_encode(array('OK' => 1)));
}
コード例 #7
0
 function upload($filepath = NULL)
 {
     $data = $this->input->post();
     if (empty($data)) {
         crud_error("Error: Empty Data !");
     }
     $this->load->library('Plupload');
     $oPlupload = new PluploadHandler();
     $oPlupload->no_cache_headers();
     $oPlupload->cors_headers();
     $config['target_dir'] = empty($filepath) ? "./tmp/" : $filepath;
     $config['allow_extensions'] = 'jpg,jpeg,png';
     if (!$oPlupload->handle($config)) {
         crud_error($oPlupload->get_error_code() . ": " . $oPlupload->get_error_message());
     }
     crud_success(array('OK' => 1));
 }