本文整理汇总了PHP中Illuminate\Support\Facades\Storage::files方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::files方法的具体用法?PHP Storage::files怎么用?PHP Storage::files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Storage
的用法示例。
在下文中一共展示了Storage::files方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileName
public function getFileName($file, $folder, $mode)
{
switch ($mode) {
case 'default':
$newFileName = str_random(10) . '.' . $file->getClientOriginalExtension();
break;
case 'ai':
$explodeFolder = explode('/', $folder);
$lastFolder = end($explodeFolder);
$files = Storage::files($folder);
if (count($files) < 1) {
$newFileName = $lastFolder . '-1' . '.' . $file->getClientOriginalExtension();
} else {
sort($files, SORT_NATURAL);
$fileName = explode('/', end($files));
$increment = explode('-', explode('.', end($fileName))[0])[1] + 1;
$newFileName = $lastFolder . '-' . $increment . '.' . $file->getClientOriginalExtension();
}
break;
case 'replace':
$newFileName = $file->getClientOriginalName();
break;
}
return $newFileName;
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$files = Storage::files('posts');
foreach ($files as $file) {
$this->call('post:one', ['name' => substr($file, 6)]);
}
}
示例3: videoPlayer
public function videoPlayer($video, $subtitle = '')
{
$subtitles = Storage::files("subtitle");
foreach ($subtitles as &$array_subtitle) {
$array_subtitle = str_replace('subtitle/', '', $array_subtitle);
}
return view('video-player')->with(compact('video'))->with(compact('subtitles'))->with(compact('subtitle'));
}
示例4: clean
public function clean()
{
$user = Auth::user();
$email = $user->email;
$files = Storage::files($email);
Storage::delete($files);
return redirect('auth/logout');
}
示例5: getBackupData
public function getBackupData()
{
$directory = "Backups";
$files = Storage::files($directory);
$json_array = array();
foreach ($files as $file) {
$temp_arr = array("path" => $file);
array_push($json_array, $temp_arr);
}
return response()->json(['data' => $json_array]);
}
示例6: files
/**
* returns json response to list the files within a directory
* @param Request $request
* @return mixed
*/
public function files(Request $request)
{
$dir = $request->get('directory');
$files = [];
foreach (Storage::files($dir) as $file) {
$result = new \stdClass();
$result->name = basename($file);
$result->directory = $dir;
$result->path = '/' . $dir . '/' . basename($file);
$result->fullPath = \URL::to($dir) . '/' . basename($file);
$result->backgroundImage = "url('{$result->path}')";
$result->active = false;
$files[] = $result;
}
return response()->json($files);
}
示例7: upload_files
/**
* this is the only method u need to call from ur controller.
*
* @param [type] $new_name [description]
*
* @return [type] [description]
*/
public function upload_files()
{
$adapter = new GoogleDriveAdapter($this->service, Cache::get('folder_id'));
$filesystem = new Filesystem($adapter);
// here we are uploading files from local storage
// we first get all the files
$files = Storage::files();
// loop over the found files
foreach ($files as $file) {
// remove file from google drive in case we have something under the same name
// comment out if its okay to have files under the same name
$this->remove_duplicated($file);
// read the file content
$read = Storage::get($file);
// save to google drive
$filesystem->write($file, $read);
// remove the local file
Storage::delete($file);
}
}
示例8: index
public function index(Request $request)
{
$available_backups = Storage::files($this->BACKUP_DIRECTORY);
$saved_backups = new Collection();
//Load all previously saved backups, and package them up so they can be displayed by the view
$available_backups_index = 0;
foreach ($available_backups as $backup) {
$backup_info = new Collection();
$backup_file = Storage::get($backup);
$parsed_data = json_decode($backup_file);
$backup_info->put("index", $available_backups_index);
//We sort this later, but it needs to refer to other
$available_backups_index++;
try {
$backup_info->put("date", $parsed_data->kora3->date);
$backup_info->put("timestamp", Carbon::parse($parsed_data->kora3->date)->timestamp);
} catch (\Exception $e) {
$backup_info->put("date", "Unknown");
$backup_info->put("timestamp", Carbon::now()->timestamp);
}
try {
$backup_info->put("name", $parsed_data->kora3->name);
} catch (\Exception $e) {
$backup_info->put("name", "Unknown");
}
try {
$backup_info->put("user", $parsed_data->kora3->created_by);
} catch (\Exception $e) {
$backup_info->put("user", "Unknown");
}
$saved_backups->push($backup_info);
}
$saved_backups = $saved_backups->sortByDesc(function ($item) {
return $item->get('timestamp');
});
$request->session()->put("restore_points_available", $available_backups);
return view('backups.index', compact('saved_backups'));
}
示例9: data_running
public function data_running(Request $request)
{
$sexoffenders = Sexoffender::select(array('id', 'state_name', 'state_code', 'state_url', 'records_crawled', 'status', 'records_expected', 'started_at', 'expected_time'))->where('crawl_state', '=', 'running');
return Datatables::of($sexoffenders)->addColumn('actions', '<button data-url="/sexoffenders/queue?id={{$id}}&action=stop" class="btn btn-xs btn-danger dt-stop" data-toggle="confirmation"><i class="fa fa-stop"></i> Stop</button>
<button data-url="/sexoffenders/queue?id={{$id}}&action=pause" class="btn btn-xs btn-warning dt-pause" ><i class="fa fa-pause"></i> Pause</button>')->addColumn('history', '<a class="btn default btn-xs blue" data-toggle="modal" href="/sexoffenders/history?id={{$id}}" data-target="#history"><i class="fa fa-history"></i> History </a>')->addColumn('elapsed_time', function ($state) {
if (empty($state->started_at)) {
return '';
} else {
return '<span title="' . Carbon::createFromFormat('Y-m-d H:i:s', $state->started_at)->toDayDateTimeString() . '">' . Carbon::createFromFormat('Y-m-d H:i:s', $state->started_at)->diffForHumans() . '</span>';
}
})->addColumn('records', function ($state) {
if (empty($state->records_expected)) {
return '<i class="icon-speedometer"></i> Calculating';
} else {
$path = 'sexoffenders/' . snake_case($state->state_name) . '/';
$image_count = count(Storage::files($path));
return $state->records_crawled . " / " . $state->records_expected . " <sup> ( <i class='fa fa-image'></i> " . $image_count . ") </sup>";
}
})->editColumn('expected_time', function ($state) {
if (empty($state->expected_time)) {
return '<i class="icon-speedometer"></i> Calculating';
} else {
$expected_time = Carbon::createFromFormat('Y-m-d H:i:s', $state->expected_time);
if ($expected_time->diffInSeconds() < 150) {
$expected_time = Carbon::now()->addSeconds(150);
}
return $expected_time->diffForHumans();
}
})->editColumn('started_at', function ($state) {
if (empty($state->started_at)) {
return '';
} else {
return Carbon::createFromFormat('Y-m-d H:i:s', $state->started_at)->toDayDateTimeString();
}
})->editColumn('id', '<input type="checkbox" value="{{$id}}" name="id[]">')->editColumn('state_name', '<a href="http://www.nullrefer.com/?{{$state_url}}" target="_blank">{{$state_name}}</a>')->make(true);
}
示例10: getYedekAl
public function getYedekAl()
{
$backuplar = Storage::files('/http---localhost/');
return view('yonetim.yedekal', compact('backuplar'));
}
示例11: postFiles
public function postFiles()
{
$path = 'produccionFile/' . Request::get('serviceOrder') . '/';
$files = Storage::files($path);
$finalArray = [];
foreach ($files as $value) {
$row['name'] = substr($value, 25);
$row['path'] = $value;
$finalArray[] = $row;
}
$response = Response::json(array('success' => true, 'data' => $finalArray));
return $response;
}
示例12: getFileList
public function getFileList()
{
$files = Storage::files('/');
return response()->json($files);
}
示例13: checkIfPageExists
/**
* Check if a directory or a file already exists in the current directory
* @param string $name file or directory name
* @param string $path current directory path
* @param string $type search a file or a directory
* @return bool
*/
public function checkIfPageExists($name, $path, $type = 'file')
{
if ($type === 'file') {
$files = Storage::files($path);
foreach ($files as $file) {
$explodeFilePath = explode('/', $file);
$fileName = explode('.', $explodeFilePath[count($explodeFilePath) - 1])[0];
if ($name === $fileName) {
return true;
}
}
} else {
$directories = Storage::directories($path);
foreach ($directories as $directory) {
$explodeFilePath = explode('/', $directory);
$fileName = $explodeFilePath[count($explodeFilePath) - 1];
if ($name === $fileName) {
return true;
}
}
}
return false;
}