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


PHP File::move方法代码示例

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


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

示例1: uploadFileToStorage

 public static function uploadFileToStorage(File $file)
 {
     $filename = 'file_' . substr(md5(uniqid(rand())), 6) . '_' . $file->getClientOriginalName();
     $path = self::uploadPath();
     $file->move($path, $filename);
     return $path . DIRECTORY_SEPARATOR . $filename;
 }
开发者ID:luizgabriel,项目名称:infire,代码行数:7,代码来源:FileUploader.php

示例2: upload

 /**
  * Handle all files
  * @return void
  */
 public function upload()
 {
     foreach ($this->files as $source => $dest) {
         $file = new File($source);
         $file->move($dest['path'], $dest['filename']);
     }
 }
开发者ID:ruysu,项目名称:laravel-core,代码行数:11,代码来源:FileUploader.php

示例3: saveProduct

 public function saveProduct()
 {
     $data = Input::all();
     if (!Auth::guest()) {
         $validator = Validator::make($data, Product::$rules);
         if ($validator->passes()) {
             $user = Auth::user();
             $product = new Product();
             $product->user_id = $user->id;
             $product->product_name = $data['product_name'];
             $product->description = $data['description'];
             $product->start_price = $data['start_price'];
             $product->save();
             if (isset($data['categories']) && !empty($data['categories'])) {
                 $product->categories()->attach($data['categories']);
             }
             if (Session::has('files')) {
                 $files = Session::get('files');
                 // get session files
                 foreach ($files as $key => $file) {
                     $directory_file = public_path() . '/product_images/' . $file;
                     if (File::exists($directory_file)) {
                         File::move($directory_file, public_path() . '/product_images/product_' . $product->id . '_' . $key . '.jpg');
                     }
                 }
                 Session::forget('files');
             }
             return Response::json(array('success' => true, 'product' => $product));
         }
         return Response::json(array('success' => false, 'type' => 'form_error', 'errors' => $validator->messages()));
     }
     return Response::json(array('success' => false, 'type' => 'log_error', 'error' => 'In order to save your product, please, log in!'));
 }
开发者ID:V3ronique,项目名称:SingaporeAuction,代码行数:33,代码来源:ProductsController.php

示例4: update

 public function update()
 {
     $rules = array('name' => 'required', 'desc' => 'required', 'totalposts' => 'required|numeric');
     $validator = Validator::make(Input::all(), $rules);
     $badgeid = Input::get('id');
     if ($validator->fails()) {
         return Redirect::to('admin/editbadge/' . $badgeid)->withErrors($validator)->withInput();
     } else {
         $name = Input::get('name');
         if (Input::get('badge')) {
             $image = explode('/', Input::get('badge'));
             $image = urldecode(end($image));
             $extension = explode(".", $image);
             $extension = end($extension);
             $img = Image::make('files/' . $image);
             $img->resize(160, null, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->save('files/' . $image);
             $newname = date('YmdHis') . '_' . Str::slug($name, '_') . '.' . $extension;
             File::move('files/' . $image, 'badges/' . $newname);
         }
         $badge = Badge::find($badgeid);
         $badge->name = Input::get('name');
         $badge->description = Input::get('desc');
         if (Input::get('badge')) {
             $badge->image = $newname;
         }
         $badge->total_posts = Input::get('totalposts');
         $badge->save();
         Session::flash('success', 'Badge updated');
         return Redirect::to('admin/badges');
     }
 }
开发者ID:ChavezRuston,项目名称:fansemo,代码行数:34,代码来源:BadgeController.php

示例5: move

 /**
  * Move or rename a file
  *
  * @param   string  $from  The full path of the file to move
  * @param   string  $to    The full path of the target file
  *
  * @return  boolean  True on success
  */
 public function move($from, $to)
 {
     $ret = $this->fileAdapter->move($from, $to);
     if (!$ret && is_object($this->abstractionAdapter)) {
         return $this->abstractionAdapter->move($from, $to);
     }
     return $ret;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:16,代码来源:Hybrid.php

示例6: moveResource

 /**
  * Move the resource to the course folder.
  *
  * @param Course $post
  * @param $path
  */
 public function moveResource(Course $post, $path)
 {
     $old_path = public_path('uploads' . DIRECTORY_SEPARATOR . $path);
     $new_path = public_path('uploads' . DIRECTORY_SEPARATOR . $post->slug);
     \File::makeDirectory($new_path, $mode = 0777, true, true);
     $new_path .= DIRECTORY_SEPARATOR . $path;
     \File::move($old_path, $new_path);
 }
开发者ID:bohap,项目名称:online-study,代码行数:14,代码来源:ResourceService.php

示例7: whenAccountWasInstalled

 public function whenAccountWasInstalled(AccountWasInstalled $account)
 {
     $langPath = app_path('lang');
     $enPath = "{$langPath}/en";
     $enGbPath = "{$langPath}/en_GB";
     if (File::exists($enPath)) {
         File::move($enPath, $enGbPath);
     }
 }
开发者ID:kamaroly,项目名称:shift,代码行数:9,代码来源:MoveLanguageFiles.php

示例8: move

 public function move($destination)
 {
     $destination = dirname($destination) . '/' . basename($this->source);
     if (File::move($this->source, $destination)) {
         $this->source = $destination;
         return true;
     } else {
         return false;
     }
 }
开发者ID:reneolivo,项目名称:PHP-Toolkit,代码行数:10,代码来源:FileInterface.php

示例9: upload

 /**
  * @ORM\PostPersist()
  * @ORM\PostUpdate()
  */
 public function upload()
 {
     if (null === $this->file) {
         return;
     }
     // s'il y a une erreur lors du déplacement du fichier, une exception
     // va automatiquement être lancée par la méthode move(). Cela va empêcher
     // proprement l'entité d'être persistée dans la base de données si
     // erreur il y a
     $this->file->move($this->getUploadRootDir(), $this->src);
     unset($this->file);
 }
开发者ID:jojotjebaby,项目名称:Bestfootball,代码行数:16,代码来源:Picture.php

示例10: upload

 /**
  * @ORM\PostPersist()
  * @ORM\PostUpdate()
  */
 public function upload()
 {
     if (null === $this->file) {
         return;
     }
     // s'il y a une erreur lors du déplacement du fichier, une exception
     // va automatiquement être lancée par la méthode move(). Cela va empêcher
     // proprement l'entité d'être persistée dans la base de données si
     // erreur il y a
     $this->file->move($this->getUploadRootDir(), $this->path);
     unset($this->file);
 }
开发者ID:jamelzouaghui,项目名称:UploadCropImageBundle,代码行数:16,代码来源:Media.php

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param  PhotosRequest  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(PhotosRequest $request, $id)
 {
     $photo = Photos::findOrFail($id);
     $old_slug = $photo->slug;
     $input = \Input::all();
     $input['slug'] = '/img/photos/' . $photo->id . '/' . \trslug::trslug(\Input::get('title') . '.jpg');
     $photo->update($input);
     \File::move(storage_path('app') . $old_slug, storage_path('app') . $photo->slug);
     //
     Photos::findOrFail($id)->update(\Input::all());
     return \Redirect::back()->with('message', 'Kaydedildi!');
 }
开发者ID:karpuzkan,项目名称:laravel,代码行数:19,代码来源:PhotosController.php

示例12: upload

 /**
  * 
  * @ORM\PostPersist()
  * @ORM\PostUpdate()
  * 
  */
 public function upload()
 {
     if (null === $this->file) {
         return;
     }
     //Si ancien fichier on supprime
     if (null !== $this->tempFileName) {
         $oldFile = $this->getUploadRootDir() . '/' . $this->id . '.' . $this->tempFileName;
         if (file_exists($oldFile)) {
             unlink($oldFile);
         }
     }
     //On deplace
     $this->file->move($this->getUploadRootDir(), $this->id . '.' . $this->url);
     //        chmod($this->getUploadRootDir().'/'.$this->id.'.'.$this->url,644);
 }
开发者ID:Rem00756,项目名称:webdyn,代码行数:22,代码来源:Image.php

示例13: upload

 /**
  * Called after entity persistence
  *
  * @ORM\PostPersist()
  * @ORM\PostUpdate()
  */
 public function upload()
 {
     // The file property can be empty if the field is not required
     if (null === $this->file) {
         return;
     }
     // Use the original file name here but you should
     // sanitize it at least to avoid any security issues
     // move takes the target directory and then the
     // target filename to move to
     $this->file->move($this->getUploadRootDir(), $this->path);
     // Set the path property to the filename where you've saved the file
     //$this->path = $this->file->getClientOriginalName();
     // Clean up the file property as you won't need it anymore
     $this->file = null;
 }
开发者ID:kozmon,项目名称:teachme,代码行数:22,代码来源:Image.php

示例14: importProcess

function importProcess()
{
    $resultData = File::uploadMultiple('theFile', 'uploads/tmp/');
    $total = count($resultData);
    for ($i = 0; $i < $total; $i++) {
        $targetPath = '';
        $theFile = $resultData[$i];
        $sourcePath = ROOT_PATH . $theFile;
        $shortPath = 'contents/plugins/' . basename($theFile);
        $targetPath .= $shortPath;
        File::move($sourcePath, $targetPath);
        $sourcePath = dirname($sourcePath);
        rmdir($sourcePath);
        File::unzipModule($targetPath, 'yes');
        $installFile = ROOT_PATH . $shortPath . '/install/update.sql';
        if (file_exists($installFile)) {
            Database::import($installFile);
        }
    }
}
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:20,代码来源:plugins.php

示例15: update

 public function update()
 {
     $id = Input::get('id');
     $rules = array('image_banner' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('admin/editbanner/' . $id)->withErrors($validator)->withInput();
     } else {
         $image = explode(url() . '/', Input::get('image_banner'));
         $realpath = public_path($image[1]);
         $newname = date('YmdHis') . '.jpg';
         File::move($realpath, 'images/slider/' . $newname);
         // update db
         $banner = Banner::find($id);
         $banner->image = 'images/slider/' . $newname;
         $banner->save();
         Session::flash('success', 'Banner updated');
         return Redirect::to('admin/banners');
     }
 }
开发者ID:ChavezRuston,项目名称:fansemo,代码行数:20,代码来源:BannerController.php


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