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


PHP UploadedFile::move方法代码示例

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


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

示例1: upload

 public function upload()
 {
     if (null === $this->file) {
         return;
     }
     $this->file->move($this->getUploadRootDir(), $this->path);
     unset($this->file);
 }
开发者ID:jlm-entreprise,项目名称:core-bundle,代码行数:8,代码来源:UploadDocument.php

示例2: moveUploadedFile

 public function moveUploadedFile(UploadedFile $file, $uploadBasePath)
 {
     $originalName = $file->getOriginalName();
     // use filemtime() to have a more determenistic way to determine the subpath, otherwise its hard to test.
     $relativePath = date('Y-m', filemtime($this->file->getPath()));
     $targetFileName = $relativePath . DIRECTORY_SEPARATOR . $originalName;
     $targetFilePath = $uploadBasePath . DIRECTORY_SEPARATOR . $targetFileName;
     $ext = $this->file->getExtension();
     $i = 1;
     while (file_exists($targetFilePath) && md5_file($file->getPath()) != md5_file($targetFilePath)) {
         if ($ext) {
             $prev = $i == 1 ? "" : $i;
             $targetFilePath = $targetFilePath . str_replace($prev . $ext, $i++ . $ext, $targetFilePath);
         } else {
             $targetFilePath = $targetFilePath . $i++;
         }
     }
     $targetDir = $uploadBasePath . DIRECTORY_SEPARATOR . $relativePath;
     if (!is_dir($targetDir)) {
         $ret = mkdir($targetDir, umask(), true);
         if (!$ret) {
             throw new \RuntimeException("Could not create target directory to move temporary file into.");
         }
     }
     $file->move($targetDir, basename($targetFilePath));
     return str_replace($uploadBasePath . DIRECTORY_SEPARATOR, "", $targetFilePath);
 }
开发者ID:pembrock,项目名称:hotel,代码行数:27,代码来源:UploadFileMover.php

示例3: upload

 /**
  * @ORM\PostPersist()
  * @ORM\PostUpdate()
  */
 public function upload()
 {
     if (null === $this->file) {
         return;
     }
     // if there is an error when moving the file, an exception will
     // be automatically thrown by move(). This will properly prevent
     // the entity from being persisted to the database on error
     // moving file into /data
     $this->file->move($this->getUploadRootDir(), $this->path);
     // creating symlink to acces file from web/...
     symlink($this->getUploadRootDir() . '/' . $this->path, $this->getWebPath());
     unset($this->file);
 }
开发者ID:N7-Consulting,项目名称:Incipio,代码行数:18,代码来源:Document.php

示例4: saveFile

 protected function saveFile(UploadedFile $file)
 {
     $upload_dir = public_path('uploads/');
     $file_name = 'file-' . date('dmY-His') . '.' . $file->getClientOriginalExtension();
     try {
         if ($file->move($upload_dir, $file_name)) {
             return $file_name;
         } else {
             return false;
         }
     } catch (\Exception $ex) {
         return abort(500, $ex->getMessage());
     }
 }
开发者ID:juliardi,项目名称:jualjasa,代码行数:14,代码来源:MessageController.php

示例5: upload

 /**
  * @param UploadedFile $file
  *
  * @param null $filename
  * @return null|string
  */
 private function upload(UploadedFile $file, $filename = null)
 {
     if ($file && $file->isValid()) {
         if (!Storage::exists('page_image')) {
             Storage::makeDirectory('page_image');
         }
         if ($filename === null) {
             $filename = $this->getUniqueName('page_image', $file->getClientOriginalExtension());
         }
         $file->move('page_image', $filename);
         return $filename;
     }
     return null;
 }
开发者ID:rdehnhardt,项目名称:rdehnhardt,代码行数:20,代码来源:TagsController.php


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