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


PHP FileUpload::handleUpload方法代码示例

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


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

示例1: actionUpload

 public function actionUpload()
 {
     include __DIR__ . "./../uploader/Uploader.php";
     $upload_dir = \Yii::$app->getModule("file")->getStorageDir();
     $uploader = new \FileUpload('uploadfile');
     $fileModel = new File();
     $realName = $_GET["uploadfile"];
     // Handle the upload
     $isUplaoded = $uploader->handleUpload($upload_dir);
     $result = false;
     $errorMsg = '';
     if ($isUplaoded) {
         $fileModel = new File();
         $fileModel->setAttribute("real_name", $realName);
         $fileModel->setAttribute("name_on_server", $uploader->getSavedFileName());
         $fileModel->setAttribute("size", $uploader->getFileSize());
         if (!$fileModel->save()) {
             $uploader->rollBack();
             $errorMsg = "Entity save error";
         } else {
             if (!empty($_GET["relateTo"])) {
                 if (!$fileModel->linkWith($_GET["relateTo"])) {
                     $uploader->rollBack();
                     $fileModel->delete();
                     $errorMsg = "Entity link error";
                 } else {
                     $result = true;
                 }
             } else {
                 $result = true;
             }
         }
     } else {
         $errorMsg = $uploader->getErrorMsg();
     }
     if ($result) {
         echo json_encode(array('success' => true));
     } else {
         exit(json_encode(['success' => false, 'msg' => $errorMsg]));
     }
 }
开发者ID:AsterAI-corp,项目名称:file,代码行数:41,代码来源:StorageController.php

示例2: array

    } else {
        require '/opt/nginx/html/vendor/upload.php';
        $upload_directory = '/opt/nginx/html/public/uploads/subs';
        $allowed_extensions = array('srt');
        $max_size = 1048576;
        $uploader = new FileUpload('file');
        $ext = $uploader->getExtension();
        if (empty($ext)) {
            $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Invalid file type.'));
            $response->header('Content-Type', 'application/json');
            return $response;
        }
        $filename = uniqid(uniqid(), true) . '.' . $ext;
        $uploader->newFileName = $filename;
        $uploader->sizeLimit = $max_size;
        $result = $uploader->handleUpload($upload_directory, $allowed_extensions);
        $errors = $uploader->getErrorMsg();
        if (!empty($errors)) {
            $response = Response::json(array('result' => false, 'location' => false, 'error' => $uploader->getErrorMsg()));
            $response->header('Content-Type', 'application/json');
            return $response;
        }
        $response = Response::json(array('result' => true, 'type' => 'subs_file', 'data' => URL::to('/uploads/subs') . '/' . $filename));
        $response->header('Content-Type', 'application/json');
        return $response;
    }
});
Route::get('upload', function () {
    if (Auth::guest()) {
    } else {
        return View::make('widgets.upload');
开发者ID:naveengamage,项目名称:okaydrive,代码行数:31,代码来源:routes.php

示例3: dirname

<?php

include_once "config.php";
require dirname(__FILE__) . '/Class/Uploader.php';
// Directory where we're storing uploaded images
// Remember to set correct permissions or it won't work
$upload_dir = IMAGEDEVICES;
$valid_extensions = array('gif', 'png', 'jpeg', 'jpg');
$uploader = new FileUpload('uploadfile');
// Handle the upload
$result = $uploader->handleUpload($upload_dir);
if (!$result) {
    exit(json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg())));
}
echo json_encode(array('success' => true));
开发者ID:Basheir,项目名称:AFix,代码行数:15,代码来源:file_upload.php

示例4: htmlspecialchars

<?php

require 'Uploader.php';
//try to get the directory from the request
$dir = htmlspecialchars($_GET["dir"]);
//if it is null
if ($dir === null || $dir === "") {
    echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
    return;
} else {
    if ($dir === "files") {
        $upload_dir = '././Content/files/';
        //$valid_extensions = array('adi', 'txt', 'cabrillo.txt', 'log', 'cbr');
    } else {
        echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
        return;
    }
}
$Upload = new FileUpload('uploadfile');
$ext = $Upload->getExtension();
// Get the extension of the uploaded file
$time = time();
$Upload->newFileName = $time . '.' . $ext;
//$result = $Upload->handleUpload($upload_dir, $valid_extensions);
$result = $Upload->handleUpload($upload_dir);
if (!$result) {
    echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
} else {
    echo json_encode(array('success' => true, 'file' => $Upload->getFileName(), 'timestamp' => $time));
}
开发者ID:4x6hp,项目名称:IARC,代码行数:30,代码来源:uploadHandler.php

示例5: getallheaders

mysql_query('SET NAMES utf8');
//mysql_query('SET TIME_ZONE=\'+04:00\'');
// Mass import offers from XLSX file
if ($_REQUEST['ajax_upload_offers'] != '') {
    // Check CSRF key
    $arr_request_headers = getallheaders();
    if ($arr_request_headers['Authorization'] != CSRF_KEY) {
        echo "Wrong access key";
        exit;
    }
    require_once _TRACK_SHOW_COMMON_PATH . '/lib/uploader/uploader.php';
    $upload_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
    $valid_extensions = array('xlsx');
    $Upload = new FileUpload('ajax_upload_offers');
    $Upload->newFileName = 'offers.xlsx';
    $result = $Upload->handleUpload($upload_dir, $valid_extensions);
    if (!$result) {
        echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg()));
    } else {
        require_once _TRACK_SHOW_COMMON_PATH . '/lib/excel-reader/excel_reader.php';
        require_once _TRACK_SHOW_COMMON_PATH . '/lib/excel-reader/SpreadsheetReader.php';
        $reader = new SpreadsheetReader($upload_dir . '/' . $Upload->getFileName());
        $i = 0;
        foreach ($reader as $xls_row) {
            // Skip row with column names
            if ($i++ == 0) {
                continue;
            }
            $category_id = 0;
            // Category is set
            if (isset($xls_row[3])) {
开发者ID:conversionstudio,项目名称:cpatracker,代码行数:31,代码来源:index.php

示例6: array

$allowed_extensions = array("gif", "jpg", "jpeg", "png");
// Directory where we're storing uploaded images
$upload_dir = './upload_files';
$upload_name = 'file_' . date("Y-m-d_His.");
if (isset($_GET['file_tree'])) {
    include dirname(__FILE__) . "/extras/php_file_tree.php";
    die(php_file_tree($upload_dir, "javascript:shoWImg('[link]',[id])", $allowed_extensions));
}
if (isset($_GET['uploadfile'])) {
    require dirname(__FILE__) . '/extras/Uploader.php';
    $Upload = new FileUpload('uploadfile');
    $ext = $Upload->getExtension();
    // Get the extension of the uploaded file
    $Upload->newFileName = $upload_name . $ext;
    $result = $Upload->handleUpload($upload_dir, $allowed_extensions);
    if (!$result) {
        die(json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg())));
    } else {
        die(json_encode(array('success' => true, 'FileName' => $Upload->getFileName(), 'Size' => $Upload->getFileSize(), 'SavedFile' => $Upload->getSavedFile(), 'Extension' => $Upload->getExtension())));
    }
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>تحميل الملفات</title>
	
    <link href="./assets/css/bootstrap.min.css" rel="stylesheet">
开发者ID:onexite,项目名称:Ajax-Uploader,代码行数:30,代码来源:index.php

示例7: FileUpload

 function upload_car($id = 0)
 {
     $this->load->library('FileUpload');
     $upload_dir = 'assets/uploads/cars/';
     $uploader = new FileUpload('uploadfile');
     // Handle the upload
     $result = $uploader->handleUpload($upload_dir);
     if (!$result) {
         exit(json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg())));
     }
     $update = array('img_name' => $uploader->getFileName());
     $this->car_model->update(array('id' => $id), $update);
     echo json_encode(array('success' => true, 'fname' => $uploader->getFileName()));
     exit;
 }
开发者ID:ram-1501,项目名称:rs,代码行数:15,代码来源:dashboard.php

示例8: mkdir

<?php

require 'Uploader.php';
$uploads_path = "../../../uploads";
$entries_path = "/at-entries";
if (!file_exists($uploads_path)) {
    mkdir($uploads_path);
}
if (!file_exists($uploads_path . $entries_path)) {
    mkdir($uploads_path . $entries_path);
}
if (!file_exists($uploads_path . $entries_path . "/.htaccess")) {
    /* add htaccess file to secure entry upload folder */
    file_put_contents($uploads_path . $entries_path . "/.htaccess", "order deny,allow\ndeny from all");
}
$uploader = new FileUpload('uploadFile');
//$result = $uploader->handleUpload($user_round_path . "/");
$result = $uploader->handleUpload($uploads_path . $entries_path . "/");
if (!$result) {
    echo json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg()));
} else {
    echo json_encode(array('success' => true, 'file' => $uploader->getFileName()));
}
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:23,代码来源:uploadFile.php

示例9: FileUpload

<?php

require_once '../Simple-Ajax-Uploader/extras/Uploader.php';
$uploader = new FileUpload('imgfile');
$result = $uploader->handleUpload('uploadDir/');
if (!$result) {
    echo json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg()));
} else {
    echo json_encode(array('success' => true, 'file' => $uploader->getFileName()));
}
开发者ID:drupalconnect,项目名称:finsearches,代码行数:10,代码来源:save.php

示例10: uploadFile

 public function uploadFile()
 {
     $requestsPerHour = 60;
     $key = sprintf('api:%s', Request::getClientIp());
     $get_data = DB::table('limit')->where('ip', $key)->first();
     if (isset($get_data->ip)) {
         $count = $get_data->count;
         $count++;
         DB::table('limit')->where('ip', $key)->update(array('count' => $count));
     } else {
         DB::table('limit')->insert(array('user_id' => Auth::user()->id, 'ip' => $key, 'count' => 0));
     }
     $count = UserMedia::where('user_id', '=', Auth::user()->id)->where('is_deleted', '=', '0')->where('cat', '=', '1')->count();
     //if($count >= 2 && Auth::user()->category_id == 1){
     //	$response = Response::json(array('result'=>false, 'location' => false,'error'=>'Free accounts are only allowed 2 torrents per account.' ));
     //	$response->header('Content-Type', 'application/json');
     //	return $response;
     //}
     $user_media = UserMedia::where('user_id', '=', Auth::user()->id)->where('is_deleted', '=', '0')->get();
     if (count($user_media) != 0) {
         $uma = array();
         foreach ($user_media as $um) {
             array_push($uma, $um->media_id);
         }
         $media_count = Media::whereIn('id', $uma)->where('state', '!=', 'done')->where('state', '!=', 'max_pause')->where('state', '!=', 'failed')->where('state', '!=', 'process')->where('state', '!=', 'stop')->count();
         if ($media_count >= 1 && Auth::user()->category_id == 1) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Free accounts are only allowed 1 active torrent per account.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
         if ($media_count >= 10) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Your account is only allowed 10 active torrents.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
     }
     if (Auth::user()->category_id == 1) {
         $status = true;
         $useage = Auth::user()->used_bytes;
         if ($useage > Auth::user()->avl_bytes) {
             $status = false;
         }
         if (Auth::user()->avl_bytes - $useage < 104857600) {
             $status = false;
         }
         date_default_timezone_set('Pacific/Auckland');
         $ip_date = date("Y-m-d");
         $ip_bytes = DataIp::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('date', '=', $ip_date)->sum('bytes');
         if (1073741824 - $ip_bytes < 104857600) {
             $status = false;
         }
         if (!$status) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Low bandwidth left on your account. Upgrade your account to premium.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
     }
     require '/opt/nginx/html/vendor/upload.php';
     $upload_directory = '/opt/nginx/html/public/cache/tmp';
     $allowed_extensions = array('torrent');
     $max_size = 1048576;
     $uploader = new FileUpload('file');
     $ext = $uploader->getExtension();
     if (empty($ext)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Invalid file type.'));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     $filename = uniqid(uniqid(), true) . '.' . $ext;
     $uploader->newFileName = $filename;
     $uploader->sizeLimit = $max_size;
     $result = $uploader->handleUpload($upload_directory, $allowed_extensions);
     $errors = $uploader->getErrorMsg();
     if (!empty($errors)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => $uploader->getErrorMsg()));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     $file = $uploader->getSavedFile();
     $url = 'http://s01.okaydrive.com/rt/php/addtorrent2.php';
     $myvars = 'torrents_start_stopped=1&url=https://okaydrive.com/cache/tmp/' . $filename;
     $ch = curl_init($url);
     $username = 'datalinktunnel';
     $password = 'T52UamGTrmCCGn4fJgyq';
     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($ch);
     $json = json_decode($response, true);
     $uni_id = '';
     if ($json["result"] == "success") {
         $hash = $json["hash"];
         $mediaexist = Media::where('hash', '=', $hash)->first();
         if (isset($mediaexist->id)) {
             if ($mediaexist->state == 'done' || $mediaexist->state == 'failed') {
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=remove&hash=' . $mediaexist->hash;
//.........这里部分代码省略.........
开发者ID:naveengamage,项目名称:okaydrive,代码行数:101,代码来源:MediaController.php


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