本文整理汇总了PHP中FileUpload::getSavedFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUpload::getSavedFile方法的具体用法?PHP FileUpload::getSavedFile怎么用?PHP FileUpload::getSavedFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUpload
的用法示例。
在下文中一共展示了FileUpload::getSavedFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
$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">
<link href="./assets/css/bootstrap-rtl.min.css" rel="stylesheet">
<link href="./assets/css/styles.css" rel="stylesheet">
<script src="./assets/js/jquery.min.js"></script>
示例2: dirname
//
$upload_dir = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/uploads/ssuploader/';
if (!is_dir($upload_dir)) {
mkdir($upload_dir);
}
$uploader = new FileUpload('uploadfile');
$uploader->newFileName = sanitize_file_name($uploader->getFileName()) . '_' . rand(0, 10) . '.' . $uploader->getExtension();
$result = $uploader->handleUpload($upload_dir);
//
switch ($_GET['uploadType']) {
case 'cv':
if (!$result) {
exit(json_encode(array('success' => FALSE, 'msg' => $uploader->getErrorMsg())));
} else {
///
$cv_url = SURL . '/wp-content/' . explode('wp-content', $uploader->getSavedFile())[1];
$attach_id = xsUTL::add_image($cv_url);
if ($attach_id > 0) {
echo json_encode(array('status' => TRUE, 'id' => $attach_id));
} else {
echo json_encode(array('status' => TRUE, 'msg' => 'File Upload Failed.Please try again'));
}
}
die;
break;
}
// Directory where we're storing uploaded images
// Remember to set correct permissions or it won't work
// Handle the upload
do_action('display_init');
$image_url = SURL . '/wp-content/' . explode('wp-content', $uploader->getSavedFile())[1];
示例3: dirname
<?php
include '../bin/load_system.php';
noGuest();
require dirname(__FILE__) . '/Uploader.php';
$upload_dir = '../uploaded_files';
$uploader = new FileUpload('uploadfile');
// Funktioniert auf demHandy nicht
$uploader->allowedExtensions = array("jpg", "jpeg");
$uploader->sizeLimit = 2621440;
$result = $uploader->handleUpload($upload_dir);
if (!$result) {
exit(json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg())));
}
echo json_encode(array('success' => true));
rename($uploader->getSavedFile(), '../profil_img/' . $USER["id"] . '.jpg');
示例4: 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;
//.........这里部分代码省略.........