當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。