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


PHP File::members方法代碼示例

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


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

示例1: handleCreate

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function handleCreate()
 {
     $user_id = Auth::id();
     $user = User::find($user_id);
     $user_name = $user->first_name;
     $date = HelperController::convertCurrentTime();
     $file = Input::file('file');
     $extension = $file->getClientOriginalExtension();
     // getting file extension
     $fileName = $file->getClientOriginalName();
     //$fileName=  HelperController::explodefile($fileName);//explode the file name and file's extension and retrieve only file name
     $path = '/files/' . $user_name . '/' . $date . '/' . $extension;
     $destinationPath = public_path() . $path;
     // upload path
     $upload_success = $file->move($destinationPath, $fileName);
     // uploading file to given path
     if ($upload_success) {
         $file_name_from_db = HelperController::checkFileName($fileName);
         $file_path_from_db = HelperController::checkFilePath($path);
         if ($fileName != $file_name_from_db && $path != $file_path_from_db) {
             /*
              * file data is stored in database
              * 
              */
             $db_file = new File();
             $db_file->file_name = $fileName;
             $db_file->file_path = 'files/' . $user_name . '/' . $date . '/' . $extension;
             $db_file->save();
             $db_file->members()->attach($user_id);
             //check file extension from extension collection
             $ext_from_db = HelperController::checkExtension($extension);
             if ($extension != $ext_from_db) {
                 $db_file_extension = new Extension();
                 $db_file_extension->file_extension = $extension;
                 $db_file_extension->save();
                 $db_file_extension->files()->attach($db_file);
             } elseif ($extension == $ext_from_db) {
                 //$old_extension=  Extension::where('file_extension','=',$extension)->first();
                 //$extension_id=$old_extension->id;
                 $ext_id = HelperController::getExtensionId($extension);
                 $db_file->extensions()->attach($ext_id);
             }
         }
         return Response::json('success', 200);
     } else {
         return Response::json('error', 400);
     }
     //echo $file;
 }
開發者ID:BDMADE,項目名稱:team1,代碼行數:54,代碼來源:FileController.php


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