當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileUtils::path_join方法代碼示例

本文整理匯總了PHP中FileUtils::path_join方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileUtils::path_join方法的具體用法?PHP FileUtils::path_join怎麽用?PHP FileUtils::path_join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FileUtils的用法示例。


在下文中一共展示了FileUtils::path_join方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: putIn

 /**
  * In this method, we don't modify tmp_name attribute
  * rather than that, we set the saved_path attribute
  * for location of these moved files.
  */
 public function putIn($targetDir, $targetFileName = null, $useCopy = false)
 {
     /* source file */
     $file = $this->tmp_name;
     if (!file_exists($file) && isset($_FILES[$this->column]['saved_path'])) {
         $useCopy = true;
         $file = $_FILES[$this->column]['saved_path'];
     }
     // if targetFilename is not given,
     // we should take the filename from original filename by using basename.
     if (!$targetFileName) {
         $targetFileName = basename($this->name);
     }
     // make sure we have the directory exists.
     if (!file_exists($targetDir)) {
         FileUtils::mkpath($targetDir);
     }
     // relative file path.
     $newPath = FileUtils::path_join($targetDir, $targetFileName);
     /* avoid file name duplication */
     $fileCnt = 1;
     while (file_exists($newPath)) {
         $newPath = FileUtils::path_join($targetDir, FileUtils::filename_suffix($targetFileName, '_' . $fileCnt++));
         // substr(md5_file( $file ),0,5) . '_' . $targetFileName );
     }
     /* register to $_FILES[ name ][ savedpath ]
      *
      * in CRUD action, we need to validate if a action file column's value
      * is a real upload file.
      * */
     $this->saved_path = $newPath;
     if ($useCopy) {
         copy($file, $newPath);
     } else {
         $this->move($file, $newPath);
     }
     $_FILES[$this->column]['saved_path'] = $newPath;
     return $newPath;
 }
開發者ID:azole,項目名稱:Phifty,代碼行數:44,代碼來源:UploadFile.php


注:本文中的FileUtils::path_join方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。