当前位置: 首页>>代码示例>>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;未经允许,请勿转载。