本文整理匯總了PHP中Illuminate\Support\Facades\File::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::get方法的具體用法?PHP File::get怎麽用?PHP File::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: upload
public static function upload(UploadedFile $file, $bucketName)
{
if (!$file->isValid()) {
throw new \Exception(trans('validation.invalid_file'));
}
$bucket = Bucket::find($bucketName);
if (!empty($bucket->mimeTypes()) && !in_array($file->getMimeType(), $bucket->mimeTypes())) {
throw new \Exception(trans('validation.invalid_file_type'));
}
if (!empty($bucket->maxSize()) && !in_array($file->getClientSize(), $bucket->maxSize())) {
throw new \Exception(trans('validation.invalid_file_size'));
}
$disk = Storage::disk($bucket->disk());
$media = Media::create(['mime' => $file->getMimeType(), 'bucket' => $bucketName, 'ext' => $file->guessExtension()]);
$disk->put($bucket->path() . '/original/' . $media->fileName, File::get($file));
if (is_array($bucket->resize())) {
foreach ($bucket->resize() as $name => $size) {
$temp = tempnam(storage_path('tmp'), 'tmp');
Image::make(File::get($file))->fit($size[0], $size[1])->save($temp);
$disk->put($bucket->path() . '/' . $name . '/' . $media->fileName, File::get($temp));
unlink($temp);
}
}
return $media;
}
示例2: upload
public function upload(ProductsImagesRequest $request, $id, Storage $storage)
{
$file = $request->file('image');
$extension = $file->getClientOriginalExtension();
$image = $this->productsImagesRepository->create(['product_id' => $id, 'extension' => $extension]);
$storage::disk('local_public')->put($image->id . '.' . $extension, File::get($file));
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('campaign_manage')->truncate();
DB::table('campaign_manage_country')->truncate();
DB::table('campaign_manage_date')->truncate();
DB::table('campaign_manage_time')->truncate();
$campaigns = json_decode(File::get('database/migrations/jsondata/campaigns.json'));
$default_parameters = array();
$default_parameters['countries'] = 10000;
$default_parameters['dates'] = 1000;
$default_parameters['hours'] = 100;
foreach ($campaigns as $campaign) {
$campaign = CampaignManage::create(array('id' => '', 'campaign_id' => $campaign->id, 'platform_id' => 1));
$relationships = array_intersect_key($default_parameters, array_flip(CampaignManage::$relationshipsAllowedToUpdate));
if (!empty($relationships)) {
foreach ($relationships as $relationshipType => $relationshipValue) {
if (!empty($relationshipValue)) {
if (!is_array($relationshipValue)) {
$relationshipValue = explode(',', $relationshipValue);
}
$campaign->{$relationshipType}()->sync($relationshipValue);
}
}
}
}
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$file = Request::file('xmlfile');
$type = Input::get('type');
$userid = Input::get('userid');
$alpha = Input::get('alpha');
$extension = $file->getClientOriginalExtension();
$oname = $file->getClientOriginalName();
Storage::disk('local')->put("uploads/" . $file->getClientOriginalName(), File::get($file));
$parser = new Parser();
$contents = Storage::get("uploads/" . $file->getClientOriginalName());
$rawxml = $parser->xml($contents);
$importer = new Importer();
if ($type == 'recipes') {
$importer->parseRecipe($rawxml, $userid, $alpha, 1);
}
if ($type == 'blocks') {
$importer->parseBlocks($rawxml, $userid, $alpha, 1);
}
if ($type == 'materials') {
$importer->parseMaterial($rawxml, $userid, $alpha, 1);
}
if ($type == 'items') {
$importer->parseItems($rawxml, $userid, $alpha, 1);
}
//Flash::success('You successfully imported a '.$type.' xml file for 7 Days to Die Alpha '.$alpha.'!');
return view('pages.import');
}
示例5: uploadImage
/**
* Handles upload image. Returns exception instance on error or file name on success.
*
* @param UploadedFile $uploadedFile
* @param string $context
* @param string $storage
* @param null|string $fileName
*
* @return \Exception|string
* @throws \Exception
*/
public static function uploadImage(UploadedFile $uploadedFile, $context, $storage = 'local', $fileName = null)
{
$file = Facades\File::get($uploadedFile);
/** @var Processor $processor */
$processor = app('icr.processor');
return $processor->upload($context, $file, $uploadedFile->getClientOriginalExtension(), Facades\Storage::disk($storage), $fileName);
}
示例6: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach (config('uploader') as $bucket => $config) {
if (isset($config['resize'])) {
$disk = Storage::disk($config['disk']);
$this->info('Processing ' . $bucket);
foreach (Media::where('bucket', $bucket)->get() as $image) {
$srcFile = $config['path'] . '/original/' . $image->fileName;
$this->info('Source File ' . $srcFile);
try {
if (!$disk->has($srcFile)) {
throw new Exception('File not found on source directory');
}
foreach ($config['resize'] as $name => $size) {
$temp = tempnam(storage_path('tmp'), 'tmp');
$file = $disk->get($srcFile);
Image::make($file)->fit($size[0], $size[1])->save($temp);
$destName = $config['path'] . '/' . $name . '/' . $image->fileName;
$disk->put($destName, File::get($temp));
unlink($temp);
$this->info(str_pad($name, 10) . ' >> ' . $destName);
}
} catch (Exception $e) {
$this->error('Failed to process image. ERR:' . $e->getMessage());
}
}
}
}
}
示例7: log
/**
* Open and parse the log.
*
* @access public
* @return array
*/
public function log()
{
$this->empty = true;
$log = array();
$log_levels = $this->getLevels();
$today = Carbon::today()->format('Y-m-d');
if ($this->date != $today) {
$log_file = preg_grep('/.*~$/', glob($this->path . '/api-error-' . $this->sapi . '*-' . $this->date . '.log'), PREG_GREP_INVERT);
} else {
$log_file = preg_grep('/.*~$/', glob($this->path . '/api-error-' . $this->sapi . '*.log'), PREG_GREP_INVERT);
$log_file = array_reverse($log_file);
}
if (!empty($log_file)) {
$this->empty = false;
$file = File::get($log_file[0]);
$jsonObjects = $this->json_split_objects($file);
if (!empty($jsonObjects)) {
foreach ($jsonObjects as $jsonObj) {
$json = json_decode($jsonObj, true);
$level = !empty($json['@fields']['level']) ? static::$levels[$json['@fields']['level']] : 'None';
$header = "[{$json["@timestamp"]}] " . $level . " " . preg_split("/\\n/", $json['@message'])[0];
if (strcasecmp($this->level, $level) == 0 || $this->level == 'all') {
$log[] = array('level' => $log_levels[$level], 'header' => $header, 'stack' => $json['@message']);
}
}
}
}
if (strtolower(Config::get('logviewer::log_order')) == 'desc') {
$log = array_reverse($log);
}
return $log;
}
示例8: profile
/**
* Shows the player profile
*
* @param integer $id
* @param string $name
*/
public function profile($id, $name = '')
{
// Cache key
$key = sprintf('player.%u', $id);
// Is there already a cached version for the player
$isCached = Cache::has($key);
// Get or Set cache for player
$player = Cache::remember($key, 5, function () use($id) {
$json = $this->repository->setopts(['ban.previous.server', 'ban.record.server', 'reputation', 'infractionsGlobal', 'infractionsServer.server', 'stats.server', 'specialGroups'], true)->getPlayerById($id)->toJson();
return json_decode($json);
});
$charts = Cache::remember(sprintf('player.%u.charts', $id), 5, function () use($id) {
$charts = [];
$charts['overview'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandOverview.sql'), [$id]));
$charts['spline'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandHistory.sql'), [$id]));
$charts['aliases'] = Record::where('command_type', 48)->where('target_id', $id)->select(DB::raw('record_message AS `player_name`, COUNT(record_id) AS `seen`'))->groupBy('player_name')->get();
$charts['iphistory'] = Record::where('command_type', 49)->where('target_id', $id)->where('record_message', '!=', 'No previous IP on record')->select(DB::raw('record_message AS `ip`, COUNT(record_id) AS `seen`'))->groupBy('ip')->get();
$charts['overview'] = $charts['overview']->map(function ($command) {
return [$command->label, intval($command->value)];
});
$charts['aliases'] = $charts['aliases']->map(function ($a) {
return [$a->player_name, intval($a->seen)];
});
$charts['iphistory'] = $charts['iphistory']->map(function ($ip) {
return [$ip->ip, intval($ip->seen)];
});
return $charts;
});
$groups = MainHelper::specialGroups($player->special_groups, 'player_group');
$page_title = !empty($player->ClanTag) ? sprintf('[%s] %s', $player->ClanTag, $player->SoldierName) : $player->SoldierName;
return View::make('player.profile', compact('player', 'page_title', 'charts', 'isCached', 'groups'));
}
示例9: actualizar
public function actualizar($id, Request $request)
{
try {
$rules = array('nombre' => array('required', 'string', 'min:5', 'unique:promociones,nombre' . $id), 'descripcion' => array('required', 'string', 'min:30'), 'imagen' => array('image', 'image_size:>=300,>=300'), 'inicio' => array('date'), 'fin' => array('date', 'after: inicio'));
$this->validate($request, $rules);
$registro = Promociones::find($id);
$registro->nombre = \Input::get('nombre');
$registro->descripcion = \Input::get('descripcion');
if ($archivo = BRequest::file('foto')) {
$foto = BRequest::file('imagen');
$extension = $foto->getClientOriginalExtension();
Storage::disk('image')->put($foto->getFilename() . '.' . $extension, File::get($foto));
$registro->imagen = $foto->getFilename() . '.' . $extension;
}
if ($inicio = \Input::get('inicio')) {
$registro->inicio = \Input::get('inicio');
}
if ($inicio = \Input::get('fin')) {
$registro->fin = \Input::get('fin');
}
$registro->save();
return \Redirect::route('adminPromociones')->with('alerta', 'La promocion ha sido modificada con exito!');
} catch (ValidationException $e) {
return \Redirect::action('PromocionesCtrl@editar', array('id' => $id))->withInput()->withErrors($e->get_errors());
}
}
示例10: saveImage
public function saveImage($request, $id)
{
$file = $request->file('image');
$extension = $file->getClientOriginalExtension();
$image = $this->model->create(['product_id' => $id, 'extension' => $extension]);
Storage::disk('local_public')->put($image->id . '.' . $extension, File::get($file));
}
示例11: updateFile
public function updateFile($id, Request $request)
{
$file = $request->file('updateFile');
$entry = FileRecord::where('id', '=', $id)->firstOrFail();
Storage::disk('local')->put($entry->owner_id . $entry->id . $entry->filename . "/" . ($entry->total_versions + 1), File::get($file));
$entry->total_versions = $entry->total_versions + 1;
$entry->public_version = $entry->total_versions;
$docVersions = (array) json_decode($entry->version_details);
$version = $entry->total_versions - 1;
$note = $request->updateDetails;
$date = Carbon::now();
$user = Auth::User()->fname . ' ' . Auth::User()->lname;
$versionArray = [$version => array('user' => $user, 'stamp' => $date, 'note' => $note)];
$finalVer = json_encode(array_merge($docVersions, $versionArray));
$entry->version_details = $finalVer;
$entry->save();
$admins = User::get()->where('user_type_id', 1);
foreach ($admins as $admin) {
$uploader = Auth::user()->fname . " " . Auth::user()->lname . " (" . Auth::user()->username . ")";
Mail::queue('mail.adminFileUpdate', ['uploader' => $uploader, 'fileName' => $entry->filename, 'id' => $entry->id, 'version' => $entry->public_version], function ($message) use(&$admin) {
$message->to($admin->email, $admin->fname)->subject('New File Update');
});
}
return redirect('/');
}
示例12: savePost
public function savePost()
{
$post = ['title' => Input::get('title'), 'content' => Input::get('content'), 'picture' => Input::get('picture')];
$rules = ['title' => 'required', 'content' => 'required'];
$valid = Validator::make($post, $rules);
if ($valid->passes()) {
$post = new Post($post);
$post->comment_count = 0;
$post->read_more = strlen($post->content) > 120 ? substr($post->content, 0, 120) : $post->content;
/*
$destinationPath = 'uploads'; // upload path
//$extension = Input::file('image')->getClientOriginalExtension(); // getting image extension
$fileName = time(); // renameing image
Input::file('images')->make($destinationPath, $fileName); // uploading file to given path
$post->images = Input::get($fileName);
$pic = Input::file('picture');
$pic_name = time();
Image::make($pic)->save(public_path().'/images/300x'.$pic_name);
$post->images = '/images/'.'300x'.$pic_name;
$post->images = Input::get($pic_name);
*/
$file = Request::file('picture');
$extension = $file;
Images::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
$post->images = $file->time();
$post->save();
return Redirect::to('admin/dash-board')->with('success', 'Post is saved!');
} else {
return Redirect::back()->withErrors($valid)->withInput();
}
}
示例13: add
public function add()
{
$file = Request::file('file');
if (Request::hasFile('file')) {
$extension = $file->getClientOriginalExtension();
Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
$entry = new \App\File();
$entry->mime = $file->getClientMimeType();
$entry->original_filename = $file->getClientOriginalName();
$entry->filename = $file->getFilename() . '.' . $extension;
$entry->save();
$part = new Part();
$part->file_id = $entry->id;
$part->name = Request::input('name');
$part->sku = Request::input('sku');
$part->make = Request::input('make');
$part->year = Request::input('year');
$part->condition = Request::input('condition');
$part->description = Request::input('description');
$part->price = Request::input('price');
$part->imageurl = Request::input('imageurl');
if (Request::has('price')) {
$part->save();
}
}
return redirect('/admin/part');
}
示例14: add
public function add(Request $request)
{
$name = Input::get('user_name');
$id = Input::get('user_id');
$text = Input::get('description');
if ($request->hasFile('filefield')) {
$file = $request->file('filefield');
$entry = new Fileentry();
$filename = time() . '.' . $file->getClientOriginalExtension();
$extension = $file->getClientOriginalExtension();
// Image::make($file)->orientate()->save(public_path('recipe/'. $filename));
Storage::disk('local')->put($file->getFileName() . '.' . $extension, File::get($file));
$entry->mime = $file->getClientMimeType();
$entry->original_filename = $file->getClientOriginalName();
$entry->filename = $file->getFilename() . '.' . $extension;
}
$entry->user_name = $name;
$entry->user_id = $id;
$entry->description = $text;
$entry->save();
// $file = Request::file('filefield');
// $extension = $file->getClientOriginalExtension();
// Storage::disk('local')->put($file->getFilename().'.'.$extension, File::get($file));
// $entry = new Fileentry();
// $entry->mime = $file->getClientMimeType();
// $entry->original_filename = $file->getClientOriginalName();
// $entry->filename = $file->getFilename().'.'.$extension;
// $entry->user_name = $name;
// $entry->user_id = $id;
// $entry->description = $text;
//
// $entry->save();
return redirect('/');
}
示例15: saveImage
public function saveImage($path, $filename, $file)
{
$image = File::get($file);
$fullpath = $path . $filename;
Storage::disk('local')->put($fullpath, $image);
return $fullpath;
}