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


PHP File::isFile方法代码示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['opening' => 'required', 'dimensions' => 'required', 'address' => 'required', 'capacity' => 'required']);
     $santiago = Santiago::find($id);
     if ($request->file('edit-santiago-photo')) {
         $this->validate($request, ['edit-santiago-photo' => 'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $santiagoFile = $santiago->photo_path . $santiago->photo_name;
         if (\File::isFile($santiagoFile)) {
             \File::delete($santiagoFile);
         }
         $file = $request->file('edit-santiago-photo');
         $santiago_photo_path = $this->_santiago_photo_path;
         $santiago_photo_name = $file->getClientOriginalName();
         $file->move($santiago_photo_path, $santiago_photo_name);
         $santiago->photo_name = $santiago_photo_name;
         $santiago->photo_path = $santiago_photo_path;
     }
     $santiago->opening = $request->get('opening');
     $santiago->dimensions = $request->get('dimensions');
     $santiago->address = $request->get('address');
     $santiago->capacity = $request->get('capacity');
     $santiago->save();
     flash()->success('', 'Santiago redaguotas!');
     return Redirect::to('/dashboard/santiago/');
 }
开发者ID:leloulight,项目名称:RealMadrid,代码行数:32,代码来源:SantiagoController.php

示例2: update

 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required', 'lastname' => 'required', 'password' => 'required|min:6', 'email' => 'required|email']);
     $user = User::find($id)->first();
     if ($request->file('edit-user-photo')) {
         $this->validate($request, ['edit-user-photo' => 'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $userFile = $user->avatar_path . $user->avatar;
         if (\File::isFile($userFile)) {
             \File::delete($userFile);
         }
         $file = $request->file('edit-user-photo');
         $avatar_path = $this->_user_photo_path;
         $avatar = $file->getClientOriginalName();
         $file->move($avatar_path, $avatar);
         $user->avatar = $avatar;
         $user->avatar_path = $avatar_path;
     }
     $user->name = $request->get('name');
     $user->lastname = $request->get('lastname');
     $user->email = $request->get('email');
     $user->password = bcrypt($request->get('password'));
     $user->save();
     flash()->success('', 'Redaguotas!');
     return redirect()->back();
 }
开发者ID:leloulight,项目名称:RealMadrid,代码行数:25,代码来源:UserController.php

示例3: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     foreach ($this->helpers as $helper) {
         $helper_path = app_path() . '/Helpers/' . $helper . '.php';
         if (\File::isFile($helper_path)) {
             require_once $helper_path;
         }
     }
 }
开发者ID:evgenlytkin,项目名称:laravel,代码行数:14,代码来源:HelpersServiceProvider.php

示例4: __construct

 public function __construct(File $file)
 {
     if (!$file->isFile()) {
         throw new CsvParseException("Could not open file");
     }
     $this->filepath = $file;
     $this->index = -1;
     $this->currentline = null;
     $this->file = null;
 }
开发者ID:perryflynn,项目名称:PerrysLambda,代码行数:10,代码来源:LineIterator.php

示例5: getExtraSecondaryAttribute

 public function getExtraSecondaryAttribute($value)
 {
     $live_path = 'uploads/thumbs/';
     $location = public_path($live_path);
     $filename = $this->hash . "_bg" . "." . pathinfo($value, PATHINFO_EXTENSION);
     if (\File::isFile($location . $filename)) {
         return asset($live_path . $filename);
     }
     return $value;
 }
开发者ID:GMSteuart,项目名称:PandaLove,代码行数:10,代码来源:Hash.php

示例6: uploadFile

 public function uploadFile($file)
 {
     if (File::isFile($file)) {
         $path = Config::get('constant.path_annex');
         $name = $this->id . '.' . $file->getClientOriginalExtension();
         $url = $path . '/' . $name;
         $file->move($path, $name);
         $this->url = $url;
         $this->save();
     }
 }
开发者ID:andrestntx,项目名称:Education,代码行数:11,代码来源:Link.php

示例7: __actionFile

 private function __actionFile()
 {
     $FileManager =& $this->_Parent->ExtensionManager->create('filemanager');
     $context = $this->_context;
     array_shift($context);
     $path = DOCROOT . $FileManager->getStartLocation() . (is_array($context) && !empty($context) ? '/' . implode('/', $context) . '/' : NULL);
     $permission = $_POST['fields']['file']['permissions'];
     $content = $_POST['fields']['file']['contents'];
     $filename = $_POST['fields']['file']['name'];
     $file = new File($path . '/' . $filename);
     $file->setContents($content);
     $file->setPermissions($permission);
     return $file->isFile();
 }
开发者ID:andrrr,项目名称:filemanager,代码行数:14,代码来源:content.new.php

示例8: download

 /** 
  * Force a file download by setting headers.  
  * @param string path to file 
  * @param string extension 
  * @param string file name on client side  
  * @example download('folder/error_log.pdf') 
  * @example download('folder/error_log.pdf', 'pdf' ,'log.pdf')  
  * @return boolean
  */
 public static function download($path = false, $extension = false, $name = false)
 {
     if ($path && File::isFile($path)) {
         if (!$extension) {
             $extension = File::extension($path);
         }
         if (!$name) {
             $name = basename($path);
         }
         header('Content-Type: application/' . $extension);
         header("Content-Transfer-Encoding: Binary");
         header("Content-disposition: attachment; filename=" . $name);
         readfile($path);
         exit;
     }
     return false;
 }
开发者ID:prototypeblocks,项目名称:php-file,代码行数:26,代码来源:File.php

示例9: register

 public function register()
 {
     // Add gallery css to backend forms
     Event::listen('backend.form.extendFields', function ($widget) {
         $pages = ['RainLab\\Blog\\Models\\Post'];
         if (in_array(get_class($widget->model), $pages)) {
             // Add our gallery styles
             $widget->getController()->addCss('/plugins/nsrosenqvist/baguettegallery/assets/css/gallery_layouts.css');
             $theme = Theme::getActiveTheme();
             // Check if the theme has a css file that needs to be included too
             if (Filesystem::isFile($theme->getPath() . '/partials/baguetteGallery/galleries.css')) {
                 $themeDir = '/' . ltrim(Config::get('cms.themesPath'), '/') . '/' . $theme->getDirName();
                 $widget->getController()->addCss($themeDir . '/partials/baguetteGallery/galleries.css');
             }
         }
     });
 }
开发者ID:nsrosenqvist,项目名称:october-plugin_baguettegallery,代码行数:17,代码来源:Plugin.php

示例10: testWrite

 public function testWrite()
 {
     $file = new File('/tmp/test');
     $this->assertEquals(true, $file->append("test\n"));
     $this->assertEquals(true, $file->append("test\n"));
     $this->assertEquals(true, $file->copy('/tmp/test2'));
     $this->assertEquals(true, $file->delete());
     $file = new File('/tmp/test2');
     $linecount = 0;
     foreach ($file->lines() as $line) {
         $linecount = $linecount + 1;
     }
     $array = $file->toArray();
     $this->assertEquals(2, count($array));
     $this->assertEquals(2, $linecount);
     $this->assertEquals(true, $file->delete());
     $this->assertEquals(false, $file->isFile());
 }
开发者ID:seanyainkiranina,项目名称:completecontrol,代码行数:18,代码来源:filetest.class.php

示例11: __construct

 public function __construct(File $file, CsvParser $settings)
 {
     if (!$file->isFile()) {
         throw new CsvParseException("Could not open file");
     }
     $this->index = 0;
     $this->currentline = null;
     $this->header = null;
     $this->columncount = null;
     $this->file = fopen($file, 'r');
     $this->settings = $settings;
     if ($this->settings->hasHeader()) {
         $temp = $this->parseLine();
         if (!is_array($temp)) {
             throw new CsvParseException("Could not parse header");
         }
         $this->header = $temp;
     }
 }
开发者ID:perryflynn,项目名称:PerrysLambda,代码行数:19,代码来源:CsvIterator.php

示例12: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $namespace = "Tablas";
     //borrramos generaciones previas
     File::deleteDirectory(app_path('contraladores_generados'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('contraladores_generados'), 777);
     $this->info("Buscando modelos");
     $models = File::files(app_path('models'));
     foreach ($models as $model) {
         if (File::isFile($model)) {
             $baseText = File::get(app_path('controllers/templates/Template.txt'));
             $controllerName = str_plural_spanish(str_replace('.php', '', basename($model))) . 'Controller';
             $this->info("Generando controller: " . $controllerName);
             //replace class name..
             $baseText = str_replace('@class_name@', $controllerName, $baseText);
             //replace namespace..
             $baseText = str_replace('@namespace@', $namespace, $baseText);
             File::put(app_path('contraladores_generados/' . $controllerName . '.php'), $baseText);
         }
     }
 }
开发者ID:richarrieta,项目名称:miequipo,代码行数:27,代码来源:GenerarControladores.php

示例13: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //borrramos generaciones previas
     File::deleteDirectory(app_path('vistas_generadas'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('vistas_generadas'), 777);
     $this->info("Buscando modelos");
     $models = File::files(app_path('models'));
     foreach ($models as $model) {
         if (File::isFile($model)) {
             $modelName = str_replace('.php', '', basename($model));
             if ($modelName != 'BaseModel') {
                 $modelInstance = new $modelName();
                 $collectionName = lcfirst(str_plural_spanish($modelName));
                 $baseText = File::get(app_path('controllers/templates/View.txt'));
                 $baseText = str_replace('@model_name@', $modelName, $baseText);
                 $baseText = str_replace('@pretty_name@', $modelInstance->getPrettyName(), $baseText);
                 $baseText = str_replace('@collection_name@', $collectionName, $baseText);
                 $basePath = app_path('vistas_generadas');
                 $this->info("Generando vista: " . $collectionName);
                 File::put($basePath . '/' . $collectionName . '.blade.php', $baseText);
                 $baseText = File::get(app_path('controllers/templates/Form.txt'));
                 $baseText = str_replace('@var_name@', lcfirst($modelName), $baseText);
                 $baseText = str_replace('@pretty_name@', $modelInstance->getPrettyName(), $baseText);
                 $baseText = str_replace('@collection_name@', $collectionName, $baseText);
                 $fieldsStr = "";
                 $fields = $modelInstance->getFillable();
                 foreach ($fields as $key) {
                     $fieldsStr .= "{{Form::btInput(\$" . lcfirst($modelName) . ", '" . $key . "', 6)}}" . PHP_EOL;
                 }
                 $baseText = str_replace('@fields@', $fieldsStr, $baseText);
                 $basePath = app_path('vistas_generadas');
                 $this->info("Generando formulario: " . $collectionName);
                 File::put($basePath . '/' . $collectionName . 'form.blade.php', $baseText);
             }
         }
     }
 }
开发者ID:richarrieta,项目名称:miequipo,代码行数:43,代码来源:GenerarVistas.php

示例14: process

 /**
  * Upload an image
  * Validates is an image
  * Saves image through intervention, optimizing and constraining to max size
  * Saves to public/uploads directory, with unique filename
  * @return string $image filename | throws Exception on error
  */
 public function process($file)
 {
     // Make sure upload directory exists
     static::directoryExists(public_path() . '/' . $this->uploadDirectory);
     // Validate file is image
     $validation = Validator::make(['file' => $file], ['file' => 'mimes:jpeg,png,gif']);
     if (!$validation->fails()) {
         $destination = public_path() . '/' . $this->uploadDirectory . '/' . $file->getClientOriginalName();
         if (File::isFile($destination)) {
             $basename = basename(isset($file->fileSystemName) ? $file->fileSystemName : $file->getClientOriginalName(), $file->getClientOriginalExtension());
             // Remove trailing period
             $basename = rtrim($basename, '.');
             // Append 1 and recheck
             $counter = 1;
             $destination = public_path() . '/' . $this->uploadDirectory . '/' . $basename . '_' . $counter . '.' . $file->getClientOriginalExtension();
             while (File::isFile($destination)) {
                 $counter++;
                 $destination = public_path() . '/' . $this->uploadDirectory . '/' . $basename . '_' . $counter . '.' . $file->getClientOriginalExtension();
             }
         }
         // Constrain image to maximum width if needed, respecting aspect ratio
         Image::make($file)->widen(1200, function ($constraint) {
             $constraint->upsize();
         })->save($destination);
         // Image has been saved to it's destination, set attributes
         if (empty($this->user_id)) {
             $user = Confide::user();
             $this->user_id = $user->id;
         }
         $this->path = $this->uploadDirectory;
         $this->filename = str_replace(public_path() . '/' . $this->uploadDirectory . '/', '', $destination);
         $this->save();
         return;
     }
     throw new Exception("There was an error uploading the image. Please upload an image with jpg, png or gif filetype");
 }
开发者ID:FebriPratama,项目名称:pop,代码行数:43,代码来源:Upload.php

示例15: File

out::prntln("Last index of 'o': " . ((!$hello->lastIndexOf("o")) ? 'false' :  $hello->lastIndexOf("o")));

// ----------------------------------------------------- //

// New Section
out::prntln();

// ----------------------------------------------------- //

// Initialize a File
$file = new File("index.php");

// Get the name
out::prntln("Filename? " . $file->getName());

// Is it a file?
out::prntln("File? " . (($file->isFile()) ? 'true' : 'false'));

// Check validation.
out::prntln("Does it exist? " . (($file->exists()) ? 'true' : 'false'));

// Attempt creation
out::prntln("Creation? " . (($file->createNewFile()) ? 'true' : 'false'));

// Size?
out::prntln("Size: " . $file->length());

// Last modified?
out::prntln("Last modified: " . $file->lastModified());

// ----------------------------------------------------- //
开发者ID:nijikokun,项目名称:java.php,代码行数:31,代码来源:Examples.java.php


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