本文整理汇总了PHP中File::get方法的典型用法代码示例。如果您正苦于以下问题:PHP File::get方法的具体用法?PHP File::get怎么用?PHP File::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($request)
{
$number = $request->getVar('number');
if (!$number) {
$number = 50;
}
if (!$request->getVar('run')) {
exit("Please supply the run= parameter, and a 'number' parameter (defaults to 50 if not set)");
}
$files = File::get()->filter(['FileSize' => 0, 'ClassName:not' => 'Folder', 'CDNFile:PartialMatch' => ':||'])->limit($number);
echo "Processing " . $number . " files<br/>\n";
flush();
foreach ($files as $file) {
echo "Downloading {$file->ClassName} #{$file->ID} " . $file->Title . " ... ";
flush();
$file->ensureLocalFile();
if ($file->localFileExists()) {
$file->FileSize = filesize($file->getFullPath());
echo "filesize {$file->FileSize} ... ";
flush();
if ($file instanceof CdnImage) {
$dim = $file->getDimensions();
echo "dimensions {$dim} ... ";
flush();
}
$file->write();
unlink($file->getFullPath());
} else {
echo " cannot download {$file->Title} - {$file->CDNFile} <br/>\n";
}
echo "<br/>\n";
}
}
示例2: testNatGeoFeed
public function testNatGeoFeed()
{
$sFilePath = "tests" . DIRECTORY_SEPARATOR . "resources" . DIRECTORY_SEPARATOR . "natgeo.xml";
$sFileContents = File::get($sFilePath);
#echo $sFileContents;
return $this->assertTrue(true);
}
示例3: __construct
public function __construct()
{
// Carbon Language
Carbon::setLocale('tr');
// create home page if non exist
count(Menu::where('slug', '/anasayfa')->get()) == 0 ? Menu::create(['title' => 'Anasayfa', 'slug' => '/anasayfa', 'eng_title' => 'Home', 'eng_slug' => '/home'])->save() : null;
// create config file if non exist
!\File::exists(storage_path('.config')) ? \File::put(storage_path('.config'), json_encode(['brand' => 'Brand Name', 'mail' => 'info@brand.com', 'active' => 1, 'eng' => '0', 'one_page' => '0', 'googlemap' => '', 'header' => ''])) : null;
$this->config = json_decode(\File::get(storage_path('.config')));
!\File::exists(storage_path('app/custom/css')) ? \File::makeDirectory(storage_path('app/custom/css'), 0755, true) : null;
!\File::exists(storage_path('app/custom/js')) ? \File::makeDirectory(storage_path('app/custom/js'), 0755, true) : null;
// get css & js files from custom folder
// css
$css = \File::allFiles(storage_path('app/custom/css'));
if (!empty($css)) {
foreach ($css as $cs) {
$this->css[$cs->getCtime()] = $cs->getRelativePathname();
}
// sort by date
ksort($this->css);
}
// js
$js = \File::allFiles(storage_path('app/custom/js'));
if (!empty($js)) {
foreach ($js as $j) {
$this->js[$j->getCtime()] = $j->getRelativePathname();
}
// sort by date
ksort($this->js);
}
}
示例4: testUploadRelation
/**
* Test that an object can be uploaded against an object with a has_one relation
*/
public function testUploadRelation()
{
$this->loginWithPermission('ADMIN');
// Unset existing has_one relation before re-uploading
$folder1 = $this->objFromFixture('Folder', 'folder1');
$record = $this->objFromFixture('SelectUploadFieldTest_Record', 'record1');
$record->FirstFileID = null;
$record->SecondFileID = null;
$record->write();
// Firstly, ensure the file can be uploaded to the default folder
$tmpFileName = 'testSelectUploadFile1.txt';
$response = $this->mockFileUpload('FirstFile', $tmpFileName);
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/SelectUploadFieldTest/FirstDefaultFolder/{$tmpFileName}");
$uploadedFile = File::get()->filter('Name', $tmpFileName)->first();
$this->assertTrue($uploadedFile instanceof File && $uploadedFile->exists(), 'The file object is created');
// If another folder is selected then a different folder should be used
$tmpFileName = 'testSelectUploadFile2.txt';
$response = $this->mockFileUpload('FirstFile', $tmpFileName, $folder1->ID);
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/SelectUploadFieldTest/{$tmpFileName}");
$uploadedFile = File::get()->filter('Name', $tmpFileName)->first();
$this->assertTrue($uploadedFile instanceof File && $uploadedFile->exists(), 'The file object is created');
$this->assertEquals(FolderDropdownField::get_last_folder(), $folder1->ID);
// Repeating an upload without presenting a folder should use the last used folder
$tmpFileName = 'testSelectUploadFile3.txt';
$response = $this->mockFileUpload('SecondFile', $tmpFileName);
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/SelectUploadFieldTest/{$tmpFileName}");
$uploadedFile = File::get()->filter('Name', $tmpFileName)->first();
$this->assertTrue($uploadedFile instanceof File && $uploadedFile->exists(), 'The file object is created');
$this->assertEquals(FolderDropdownField::get_last_folder(), $folder1->ID);
}
示例5: getAssetList
/**
* Creates table for displaying unused files.
*
* @return GridField
*/
protected function getAssetList()
{
$where = $this->folder->getUnusedFilesListFilter();
$files = File::get()->where($where);
$field = new GridField('AssetList', false, $files);
return $field;
}
示例6: addRecipes
/**
* @param array $dir
* @param $files
* @param \stdClass $category
* @return void
*/
protected function addRecipes(array $dir, $files, \stdClass $category)
{
foreach ($dir as $value) {
if ($value != "." && $value != "..") {
$file = \File::get("{$files}/{$value}");
$problem = $this->getParseContents('problem', $file);
$solution = $this->getParseContents('solution', $file);
$discussion = $this->getParseContents('discussion', $file);
$credit = $this->getParseContents('credit', $file);
$title = $this->getParseHeader('title', $file);
$position = $this->getParseHeader('position', $file);
$topics = $this->getParseHeader('topics', $file);
if ($problem && $solution && $discussion && $title) {
$array = ['problem' => trim($problem), 'category_id' => $category->category_id, 'solution' => trim($this->convertGfm($solution)), 'discussion' => trim($this->convertGfm($discussion)), 'credit' => trim($this->convertGfm($credit)), 'title' => trim($title), 'position' => trim($position)];
try {
// new recipes
$recipeId = $this->recipe->addRecipe($array);
$this->addTags($recipeId, $topics);
$this->info("added : {$files}/{$value}");
} catch (QueryException $e) {
// update recipes
$recipe = $this->recipe->getRecipeFromTitle(trim($title));
$this->recipe->updateRecipe($recipe->recipe_id, ['problem' => trim($problem), 'category_id' => $category->category_id, 'solution' => trim($this->convertGfm($solution)), 'discussion' => trim($this->convertGfm($discussion)), 'position' => trim($position)]);
$this->recipeTag->deleteRecipeTags($recipe->recipe_id);
$this->addTags($recipe->recipe_id, $topics);
$this->comment("Updated : recipe:{$title} : {$files}/{$value}");
}
}
}
}
}
示例7: run
public function run()
{
DB::table('availability_page')->delete();
$success = File::cleanDirectory($this->getImagesPath());
File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore'));
AvailabilityPage::create(['image_name' => ""]);
}
示例8: apply
public function apply(Transformable $transformable)
{
$file = \File::get(public_path('assets/img/borders.png'));
$img = base64_encode($file);
$data = str_ireplace(["\r", "\n"], '', $transformable->getContents());
$data = preg_replace("~<(/?(br|p|dd))[^>]*?>~i", '<\\1>', $data);
$data = preg_replace("~</(p|dd)>~i", '', $data);
$data = preg_replace("~<(br|p|dd)>~i", static::LINEBREAK, $data);
$data = preg_replace('/[ ]{2,}/', ' ', $data);
$data = preg_replace("/" . static::LINEBREAK . "[ ]+/s", static::LINEBREAK . " ", $data);
$data = str_replace(static::LINEBREAK, '<p>', $data);
$page = $transformable->page;
$author = $page->author;
$charset = $transformable->charset ?: 'utf-8';
$title = $author->fio . " - " . $page->title;
$link = \HTML::link(path_join("http://samlib.ru", $author->absoluteLink()), $author->fio) . " - " . \HTML::link(path_join("http://samlib.ru", $page->absoluteLink()), $page->title);
$annotation = $page->annotation;
$contents = $data;
$downloaded = \Lang::get('pages.pages.downloaded', ['url' => \Request::fullUrl()]);
if ($charset != 'utf-8') {
$e = app('charset-encoder');
$c = $e->remap($charset, true);
$title = $e->transform($title, 'utf-8', $c);
$link = $e->transform($link, 'utf-8', $c);
$annotation = $e->transform($annotation, 'utf-8', $c);
$downloaded = $e->transform($downloaded, 'utf-8', $c);
}
$view = view('pages.html-download', compact('img', 'charset', 'title', 'link', 'annotation', 'contents', 'downloaded'));
$transformable->setContents((string) $view);
$transformable->setType(static::EXTENSION);
return $transformable;
}
示例9: extraer
public function extraer()
{
$path = public_path();
$this->text = \File::get($path . $this->file);
$this->extraerProyecto();
$this->extraerNombreProyecto();
$this->extraerUrg();
$this->extraerDescUrg();
$this->extraerFechas();
$this->extraerFondo();
$this->extraerMontoProyecto();
$this->extraerPartida();
$this->extraerCog();
$this->extraerMontoPartida();
$this->extraerObjetivo();
if (count($this->arr_partida) == count($this->arr_cog) && count($this->arr_partida) == count($this->arr_monto)) {
for ($i = 0; $i < count($this->arr_partida); $i++) {
$this->arr_recursos[$this->arr_partida[$i]]['cog'] = $this->arr_cog[$i];
$this->arr_recursos[$this->arr_partida[$i]]['d_rm'] = $this->arr_drm[$i];
$this->arr_recursos[$this->arr_partida[$i]]['monto'] = $this->arr_monto[$i];
$this->arr_recursos[$this->arr_partida[$i]]['objetivo'] = $this->arr_rm_objetivo[$this->arr_partida[$i]];
$this->arr_recursos[$this->arr_partida[$i]]['d_objetivo'] = $this->arr_rm_d_objetivo[$this->arr_partida[$i]];
}
}
}
示例10: upload_file
function upload_file($file)
{
$extension = $file->getClientOriginalExtension();
$filename = $file->getFilename() . '.' . $extension;
Storage::disk('local')->put($filename, File::get($file));
return $filename;
}
示例11: getFile
/**
* Funcao para edicao da config do [Modulo]
* @param string $controller Nome do controlador
* @return void
*/
public function getFile($controller)
{
// $this->logic->_getConfigFiles();
// Busca o arquivo especificado
$cfg_file = mkny_model_config_path($controller) . '.php';
// Field types
$f_types = array_unique(array_values(app()->make('Mkny\\Cinimod\\Logic\\AppLogic')->_getFieldTypes()));
// Se o diretorio nao existir
if (!realpath(dirname($cfg_file))) {
\File::makeDirectory(dirname($cfg_file));
}
// Config file data
if (!\File::exists($cfg_file)) {
$stub = \File::get(__DIR__ . '/../Commands/stubs/model_config.stub');
\Mkny\Cinimod\Logic\UtilLogic::translateStub(array('var_fields_data' => ''), $stub);
\File::put($cfg_file, $stub);
}
// Config file data
$config_str = \File::getRequire($cfg_file)['fields'];
// Pula o primeiro indice
// array_shift($config_str);
$valOrder = 1;
// Fornece o tipo "types" para todos os campos, para selecao
foreach ($config_str as $key => $value) {
if (!is_array($config_str[$key])) {
$config_str[$key] = array();
}
$config_str[$key]['name'] = $key;
$config_str[$key]['type'] = isset($value['type']) ? $value['type'] : 'string';
$config_str[$key]['form_add'] = isset($value['form_add']) ? $value['form_add'] : true;
$config_str[$key]['form_edit'] = isset($value['form_edit']) ? $value['form_edit'] : true;
$config_str[$key]['grid'] = isset($value['grid']) ? $value['grid'] : true;
$config_str[$key]['relationship'] = isset($value['relationship']) ? $value['relationship'] : false;
$config_str[$key]['required'] = isset($value['required']) ? $value['required'] : false;
$config_str[$key]['searchable'] = isset($value['searchable']) ? $value['searchable'] : false;
$config_str[$key]['order'] = isset($value['order']) ? $value['order'] : $valOrder++;
$config_str[$key]['types'] = array_combine($f_types, $f_types);
}
if (isset(array_values($config_str)[1]['order'])) {
usort($config_str, function ($dt, $db) {
if (!isset($db['order'])) {
$db['order'] = 0;
}
if (isset($dt['order'])) {
return $dt['order'] - $db['order'];
} else {
return 0;
}
});
$newConfig = [];
foreach ($config_str as $sortfix) {
$newConfig[$sortfix['name']] = $sortfix;
}
$config_str = $newConfig;
}
$data['controller'] = $controller;
$data['data'] = $config_str;
return view('cinimod::admin.generator.config_detailed_new')->with($data);
// return view('cinimod::admin.generator.config_detailed')->with($data);
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//obtenemos el campo file definido en el formulario
$file1 = $request->file('foto1');
$file2 = $request->file('foto2');
$file3 = $request->file('foto3');
// $input = array('image' => $file1);
// $reglas = array('image' => 'mimes:jpeg,png');
// $validacion = Validator::make($input, $reglas);
// if ($validacion->fails())
// {
// \Session::flash('flash_message', 'Una de las imagenes no es correcta');
// }
//obtenemos el nombre del archivo
$nombre1 = $file1->getClientOriginalName();
$nombre2 = $file2->getClientOriginalName();
$nombre3 = $file3->getClientOriginalName();
//indicamos que queremos guardar un nuevo archivo en el disco local
\Storage::disk('local')->put($nombre1, \File::get($file1));
\Storage::disk('local')->put($nombre2, \File::get($file2));
\Storage::disk('local')->put($nombre3, \File::get($file3));
$persona = Persona::find($request->persona_id);
$persona->fill($request->all());
$persona->foto1 = $request->persona_id . '|' . $nombre1;
$persona->foto2 = $request->persona_id . '|' . $nombre2;
$persona->foto3 = $request->persona_id . '|' . $nombre3;
$persona->save();
return view('new');
}
示例13: parse
/**
* Parse a block of YAML into PHP
*
* @param string $yaml YAML-formatted string to parse
* @param string $mode Parsing mode to use
* @return array
*/
public static function parse($yaml, $mode = null)
{
// start measuring
$hash = Debug::markStart('parsing', 'yaml');
$mode = $mode ? $mode : self::getMode();
switch ($mode) {
case 'loose':
$result = Spyc::YAMLLoad($yaml);
break;
case 'strict':
$result = sYAML::parse($yaml);
break;
case 'transitional':
try {
$result = sYaml::parse($yaml);
} catch (Exception $e) {
Log::error($e->getMessage() . ' Falling back to loose mode.', 'core', 'yaml');
$result = Spyc::YAMLLoad($yaml);
}
break;
default:
// check for new lines, is this a file?
$has_newline = strpos($yaml, "\n") !== false;
if (!$has_newline && File::exists($yaml)) {
// seems like it is
$yaml = File::get($yaml);
}
$result = Statamic\Dipper\Dipper::parse($yaml);
}
// end measuring
Debug::markEnd($hash);
Debug::increment('parses', 'yaml');
return $result;
}
示例14: addRoutes
/**
* Adds the necessary routes
*
* @return void
*/
public function addRoutes()
{
//Get the routes template content
$content = \File::get($this->package_path('Templates/routes.php'));
//Append to the routes.php file
$this->addToFile('routes.php', 'routes', "\n\n" . $content);
}
示例15: postUpload
public function postUpload(Request $req)
{
$response = array();
if ($req->file('excelF')) {
$file = $req->file('excelF');
$extension = $file->getClientOriginalExtension();
$filename = $file->getClientOriginalName();
/*periksa extensi file */
if ('xlsx' !== $extension) {
$response['code'] = 404;
$response['msg'] = "File berextensi {$extension} dengan nama {$filename}, file Seharusnya Berupa Excel";
// $response['msg']="File Anda $file->getClientOriginalName(), Pastikan File yang Anda upload sesuai dengan format ";
return $response;
// return $response;
} elseif (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
// simpan kedadalam table
$entry = new Fileentry();
$entry->mime = $file->getClientMimeType();
$entry->original_filename = $file->getClientOriginalName();
$entry->filename = $file->getFilename() . '.' . $extension;
$entry->save();
$response['code'] = 200;
$response['msg'] = "File {$entry->original_filename} Telah disimpan";
return $response;
}
}
$response['code'] = 404;
$response['msg'] = "Gagal Upload File !!!";
return json_encode($response);
// echo '{"TEST1": 454535353,"TEST2": "test2"}';
}