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


PHP File::create方法代码示例

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


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

示例1: create

 /**
  * Creates a new file using the input from the form
  *
  * @param Request  $request
  * @param $projectname project name
  * @return mixed
  */
 public function create(Request $request, $projectname)
 {
     $project = Project::where('title', $projectname)->firstOrFail();
     $this->validate($request, ['filename' => 'required|unique:files,filename,NULL,id,project_id,' . $project->id . '|max:255|regex:/([A-Za-z0-9_.-]+)/']);
     $newEntry = File::create(['project_id' => $project->id, 'projectname' => $project->title, 'filename' => $request->input('filename'), 'type' => 'File', 'description' => $request->input('description'), 'contents' => "/* " . EditorController::quoteOfTheDay() . " */", 'user_id' => Auth::user()->id, 'parent' => 0]);
     return redirect('/editor/edit/' . $newEntry->projectname . '/' . $newEntry->filename);
 }
开发者ID:uidaho,项目名称:squireproject,代码行数:14,代码来源:EditorController.php

示例2: uploadThumbAndMainImage

 public function uploadThumbAndMainImage(Request $request)
 {
     // get basic info
     $s3 = Storage::disk('s3');
     $file = $request->file('file');
     $extension = $request->file('file')->guessExtension();
     $filename = uniqid() . '.' . $extension;
     $mimeType = $request->file('file')->getClientMimeType();
     $fileSize = $request->file('file')->getClientSize();
     $image = Image::make($file);
     $galleryId = $request->input('galleryId');
     // generate the thumb and medium image
     $imageThumb = Image::make($file)->fit(320)->crop(320, 240, 0, 0);
     $imageThumb->encode($extension);
     $imageMedium = Image::make($file)->resize(800, null, function ($constraint) {
         $constraint->aspectRatio();
     });
     $imageMedium->encode($extension);
     $image->encode($extension);
     // upload image to S3
     $s3->put("gallery_{$galleryId}/main/" . $filename, (string) $image, 'public');
     $s3->put("gallery_{$galleryId}/medium/" . $filename, (string) $imageMedium, 'public');
     $s3->put("gallery_{$galleryId}/thumb/" . $filename, (string) $imageThumb, 'public');
     // make image entry to DB
     $file = File::create(['file_name' => $filename, 'mime_type' => $mimeType, 'file_size' => $fileSize, 'file_path' => env('S3_URL') . "gallery_{$galleryId}/main/" . $filename, 'type' => 's3']);
     DB::table('gallery_images')->insert(['gallery_id' => $galleryId, 'file_id' => $file->id]);
     $fileImg = File::find($file->id);
     $fileImg->status = 1;
     $fileImg->save();
     return ['file' => $fileImg, 'file_id' => $file->id, 'thumbUrl' => env('S3_URL') . "gallery_{$galleryId}/thumb/" . $filename, 'url' => env('S3_URL') . "gallery_{$galleryId}/medium/" . $filename, 'main' => env('S3_URL') . "gallery_{$galleryId}/main/" . $filename];
 }
开发者ID:yoyoo,项目名称:learningl5,代码行数:31,代码来源:File.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $items = (array) json_decode($request->input('items'));
     $connections_name = json_decode($request->input('connections_name'));
     $names = json_decode($request->input('names'));
     $sizes = json_decode($request->input('sizes'));
     $dates = json_decode($request->input('dates'));
     $path_names = json_decode($request->input('path_name'));
     $tmp_url = substr(base64_encode(sha1(mt_rand())), 0, 16);
     $link = new Link();
     $link->link_name = $request->input('lkname');
     $link->user_id = Auth::user()->id;
     $link->url = $tmp_url;
     $link->save();
     $lid = $link->id;
     $random = User::find(Auth::user()->id)->token->first()->id;
     $root = File::create(['name' => 'root', 'path' => $request->input("lkname"), 'link_id' => $lid, 'token_id' => $random]);
     foreach ($items as $index => $item) {
         $tokenName = $connections_name[$index];
         $name = $names[$index];
         $path = $item;
         $size = $sizes[$index];
         $date = $dates[$index];
         $provObj = new Provider($tokenName);
         $share_link = $provObj->getLink($path);
         //            $before_dir = str_replace('/'.basename($path), "", $path);
         $root->children()->create(['name' => $name, 'path' => $path_names[$index], 'bytes' => 0, 'size' => $size, 'mime_type' => "", 'is_dir' => $size == "" ? true : false, 'shared' => $share_link, 'modified' => $date, 'token_id' => $provObj->getTokenId(), 'link_id' => $lid]);
     }
     return Redirect::to('/gtl/' . $request->input("lkname"));
 }
开发者ID:noxfate,项目名称:gathercloud,代码行数:36,代码来源:GatherlinkController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $imgPath = $this->imageUpload($input['filepath']);
     $input['filepath'] = $imgPath;
     File::create($input);
     return redirect('file')->with('status', 'Create successfully');
 }
开发者ID:polodev,项目名称:Bard-Ftfl-Laravel-Project,代码行数:14,代码来源:FileController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateFileRequest $request)
 {
     $title = $request->get('title');
     $description = $request->get('description');
     $path = $this->storeFile($request);
     $instance = File::create(['title' => $title, 'description' => $description, 'path' => $path]);
     return response()->json(['data' => "The file {$instance->name} was created with id {$instance->id}"], 200);
 }
开发者ID:SeverMateus,项目名称:TurmaUnida,代码行数:14,代码来源:FileController.php

示例6: uploadFile

 /**
  * @param Request $request
  * @return array|\Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function uploadFile(Request $request)
 {
     try {
         try {
             DB::beginTransaction();
             $file = 'file';
             if ($request->has('filename')) {
                 $file = $request->input('filename');
             }
             $files = $request->file($file);
             if (!is_array($files)) {
                 $files[] = $request->file($file);
             }
             foreach ($files as $f) {
                 $extArr = explode("/", $f->getClientMimeType());
                 $mimeType = $f->getClientMimeType();
                 $fileSize = $f->getClientSize();
                 $originalFilename = $f->getClientOriginalName();
                 $type = 'local';
                 // check with the file extention
                 if ($extArr) {
                     $ext = $extArr[1];
                 }
                 if (!$ext) {
                     return false;
                 }
                 $fileName = uniqid() . "." . $ext;
                 if (!file_exists($this->filePath)) {
                     mkdir($this->filePath, 0777, true);
                 }
                 $f->move($this->filePath, $fileName);
                 $filePath = $this->filePath . $fileName;
                 // if the designation is s3. Upload
                 if ($request->input('destination') == 's3') {
                     $uploadPath = $request->input('path') . '/' . $fileName;
                     $type = 's3';
                     $s3 = Storage::disk('s3');
                     $s3->put($uploadPath, file_get_contents($filePath), 'public');
                     unlink($filePath);
                     $filePath = $this->s3Prefix . $uploadPath;
                 }
                 $file = File::create(['file_name' => $fileName, 'mime_type' => $mimeType, 'file_size' => $fileSize, 'file_path' => $filePath, 'client_file_name' => $originalFilename, 'type' => $type]);
                 $responseArr[] = $file;
             }
             DB::commit();
             return $responseArr;
         } catch (FileException $e) {
             return response($e->getMessage(), 500);
         }
     } catch (Exception $e) {
         DB::rollBack();
         return response('There were some errors uploading files', 500);
     }
 }
开发者ID:snehachavan21,项目名称:timesheet,代码行数:58,代码来源:FileController.php

示例7: view

 /**
  * Renders the Project Member view for the given project
  *
  * @param Project $project
  * @return The project members page view
  * @internal param 
  */
 public function view(Project $project)
 {
     $this->authorize('userIsMember', $project);
     $userid = Auth::user()->id;
     $files = File::forProject($project)->get();
     if (count($files) == 0) {
         File::create(['project_id' => $project->id, 'projectname' => $project->title, 'filename' => 'Main.java', 'type' => 'File', 'description' => 'Entry point of ' . $project->title . '.', 'contents' => '/* Program starts here. */\\npublic class Main {\\n\\tpublic static void main(String[] args) {\\n\\t\\n\\t}\\n}', 'user_id' => Auth::user()->id, 'parent' => 0]);
     }
     $files = File::forProject($project)->get();
     return view('project-members.view', ['project' => $project, 'files' => $files, 'userid' => $userid]);
 }
开发者ID:uidaho,项目名称:squireproject,代码行数:18,代码来源:ProjectMembersController.php

示例8: __construct

 /**
  * Create a new job instance.
  *
  * @return void
  */
 public function __construct($conName)
 {
     $this->connName = $conName;
     $this->connObj = new Provider($conName);
     $query = File::roots()->where('token_id', $this->connObj->getTokenId())->first();
     if ($query !== null) {
         $this->root = $query;
         //            $this->root->delete();
     } else {
         $this->root = File::create(['name' => 'root', 'path' => $this->connObj->getProvider(), 'token_id' => $this->connObj->getTokenId()]);
     }
 }
开发者ID:noxfate,项目名称:gathercloud,代码行数:17,代码来源:CreateFileMapping.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param StoreVideoRequest $request
  * @return Response
  */
 public function store(StoreVideoRequest $request)
 {
     if (!Auth::user()->can('create-video')) {
         return view('errors.denied');
     }
     $file_hash = md5($request->file('video')->getClientOriginalName() . time());
     $file_details = ['name' => $request->file('video')->getClientOriginalName(), 'title' => $request->get('title'), 'description' => $request->get('description'), 'file_hash' => $file_hash, 'extension' => $request->file('video')->getClientOriginalExtension(), 'type' => 1, 'user_id' => $request->get('author'), 'level' => $request->get('level')];
     File::create($file_details);
     $request->file('video')->move(base_path() . '/files/video/', $file_hash . '.' . $request->file('video')->getClientOriginalExtension());
     $this->extractVideoFrame($request, $file_hash);
     return Redirect::to('/video');
 }
开发者ID:nandeeshmp,项目名称:app,代码行数:18,代码来源:VideoController.php

示例10: createReferenceToFileInDB

 private function createReferenceToFileInDB($fileName, $file, $folderId, $attachId)
 {
     //if we've got no folder id passed attach this upload to users root folder
     if (!$folderId && Auth::check()) {
         $folderId = Auth::user()->folders()->where('name', 'root')->first()->id;
     } else {
         if (!$folderId) {
             $folderId = null;
         }
     }
     return File::create(['file_name' => $fileName, 'share_id' => strtolower(str_random(20)), 'name' => $this->makeTitleFromOriginalName($file), 'folder_id' => $folderId, 'attach_id' => $attachId ? $attachId : null, 'file_size' => $file->getClientSize(), 'mime' => $file->getMimeType(), 'user_id' => Auth::check() ? Auth::user()->id : null]);
 }
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:12,代码来源:FileSaver.php

示例11: createFilesForFolder

 private function createFilesForFolder($folderName, User $user, Folder $folder)
 {
     $files = Storage::files("demo-files/{$folderName}");
     foreach ($files as $file) {
         if (str_contains($file, 'Thumbs.db')) {
             continue;
         }
         //create model
         $fileName = str_random(10) . '.' . pathinfo($file, PATHINFO_EXTENSION);
         $model = File::create(['file_name' => $fileName, 'share_id' => str_random(20), 'name' => basename($file), 'mime' => $this->getMimeType($file), 'folder_id' => $folder->id, 'file_size' => filesize($file), 'user_id' => $user->id]);
         $path = 'application/storage/uploads/' . $user->id . '/' . $model->id . '/';
         Storage::copy($file, $path . $fileName);
     }
 }
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:14,代码来源:DemoContentCreator.php

示例12: redirectUpload

 public function redirectUpload()
 {
     sleep(15);
     $response = Transloadit::response();
     if ($response) {
         if (!empty($response->data['results'])) {
             $respon = $response->data['results']['upload'][0];
             $server = $response->data['fields']['server'];
             $tipe = $response->data['fields']['tipe'];
             $file = File::create(['namafile' => $respon['name'], 'size' => $respon['size'], 'url' => $respon['url'], 'server' => $server, 'status' => 0, 'tipe' => $tipe, 'idteam' => Auth::user()->team->id]);
             $job = $this->dispatch(new DownloadFileFromTransloadit($file));
             return redirect('/user/upload')->with('message', 'Upload file berhasil');
         } else {
             return redirect('/user/upload')->with('error', 'Upload gagal, silahkan cek kembali file anda');
         }
     }
     return redirect()->away(Request::url());
 }
开发者ID:notreal5400,项目名称:Vocomfest2016,代码行数:18,代码来源:UserController.php

示例13: callback

 public function callback(Request $request)
 {
     // You should set this route on your Twitter Application settings as the callback
     // https://apps.twitter.com/app/YOUR-APP-ID/settings
     if (session()->has('oauth_request_token')) {
         $request_token = ['token' => session()->get('oauth_request_token'), 'secret' => session()->get('oauth_request_token_secret')];
         Tweet::reconfig($request_token);
         $oauth_verifier = false;
         if ($request->has('oauth_verifier')) {
             $oauth_verifier = $request->input('oauth_verifier');
         }
         // getAccessToken() will reset the token for you
         $token = Tweet::getAccessToken($oauth_verifier);
         if (!isset($token['oauth_token_secret'])) {
             return redirect()->route('twitter.login')->with('flash_error', 'We could not log you in on Twitter.');
         }
         $credentials = Tweet::getCredentials();
         if (is_object($credentials) && !isset($credentials->error)) {
             // $credentials contains the Twitter user object with all the info about the user.
             // Add here your own user logic, store profiles, create new users on your tables...you name it!
             // Typically you'll want to store at least, user id, name and access tokens
             // if you want to be able to call the API on behalf of your users.
             // This is also the moment to log in your users if you're using Laravel's Auth class
             // Auth::login($user) should do the trick.
             Auth::user()->update(['bio' => $credentials->description, 'twitter' => $credentials->screen_name]);
             $profile_image_url = file_get_contents(str_replace('_normal', '', $credentials->profile_image_url));
             $profile_banner_url = file_get_contents($credentials->profile_banner_url);
             $destinationPath = 'uploads/twitter';
             $profile_image = $destinationPath . '/twitter_profile_' . $credentials->screen_name . '.jpg';
             $profile_banner = $destinationPath . '/twitter_banner_' . $credentials->screen_name . '.jpg';
             file_put_contents($profile_image, $profile_image_url);
             file_put_contents($profile_banner, $profile_banner_url);
             $file1 = File::create(['url' => $profile_image, 'original_name' => 'twitter_profile_' . $credentials->screen_name, 'type' => 'profile_photo']);
             $file2 = File::create(['url' => $profile_banner, 'original_name' => 'twitter_banner_' . $credentials->screen_name, 'type' => 'profile_cover']);
             Auth::user()->files()->sync([$file1->id, $file2->id]);
             $twitter = Twitter::first();
             $twitter_data = ['user_id' => Auth::user()->id, 'token' => $token['oauth_token'], 'secret' => $token['oauth_token_secret'], 'twitter_id' => $token['user_id'], 'screen_name' => $token['screen_name']];
             is_null($twitter) ? Twitter::create($twitter_data) : Twitter::update($twitter_data);
             session()->put('access_token', $token);
             return redirect('admin/settings?tab=networks')->with('flash_notice', 'Congrats! You\'ve successfully signed in!');
         }
         return redirect()->route('twitter.error')->with('flash_error', 'Crab! Something went wrong while signing you up!');
     }
 }
开发者ID:realnerdo,项目名称:blog,代码行数:44,代码来源:TwitterController.php

示例14: uploadImageFileFromBase64String

 /**
  * Upload image from image base64 string
  *
  * @param $fileRequestObj
  * @param $filePath
  * @param null $fileName
  * @param null $storage
  * @return static
  */
 public function uploadImageFileFromBase64String($fileRequestObj, $filePath, $fileName = null, $storage = null)
 {
     // check and set filename
     if ($fileName == null) {
         $fileName = uniqid();
     }
     // check and set path
     if (!file_exists($filePath)) {
         mkdir($filePath, 0777, true);
     }
     // check the extension of the file
     $ext = $this->getFileExtensionFromString($fileRequestObj);
     // set the storage
     $this->setStorage($storage);
     Image::make(file_get_contents($fileRequestObj))->resize(200, 200)->save($filePath . $fileName . $ext);
     if ($this->storage == 's3') {
         $this->handleS3File($filePath, $fileName, $ext);
     }
     $file = File::create(['file_name' => $fileName . $ext, 'mime_type' => '', 'file_size' => '', 'file_path' => $this->giveUrlToUri($filePath) . $fileName . $ext, 'client_file_name' => $fileName . $ext, 'type' => $this->storage]);
     return $file;
 }
开发者ID:amitavroy,项目名称:mywall,代码行数:30,代码来源:FileManager.php

示例15: postUpload

 public function postUpload(Request $request)
 {
     $this->validate($request, ['file' => 'required'], [], ['file' => '上传的文件']);
     if ($request->file('file')->isValid()) {
         $arr = array();
         $file = $request->file('file');
         $arr['filename'] = $request->get("filename") ? $request->get("filename") : str_replace('.' . $file->getClientOriginalExtension(), "", $file->getClientOriginalName());
         $arr['note'] = $request->get("note");
         $arr['type'] = $file->getClientMimeType();
         $arr['download_count'] = 0;
         $arr['upload_by'] = Auth::user()->name . "(" . Auth::user()->email . ")";
         $arr['upload_at'] = date("Y-m-d H:i:s");
         $arr['upload_id'] = Auth::user()->id;
         $arr['extension'] = '.' . $file->getClientOriginalExtension();
         $size = $file->getClientSize();
         if ($size > 1024 * 1024 * 1024) {
             $arr['size'] = round($size / (1024 * 1024 * 1024), 3) . "GB";
         } else {
             if ($size > 1024 * 1024) {
                 $arr['size'] = round($size / (1024 * 1024), 3) . "MB";
             } else {
                 if ($size > 1024) {
                     $arr['size'] = round($size / 1024, 3) . "KB";
                 } else {
                     $arr['size'] = $size . "B";
                 }
             }
         }
         $real_filename = date("YmdHis", time()) . floor((microtime(true) - time()) * 1000) . "." . $file->getClientOriginalExtension();
         $path = "upload/";
         $arr['path'] = $path . $real_filename;
         $path = storage_path() . '/app/' . $path;
         $file->move($path, $real_filename);
         File::create($arr);
         $info = array('上传成功!');
         return view('file.upload')->withTips($info);
     }
 }
开发者ID:ChenPeiyuan,项目名称:student-infomation-manager,代码行数:38,代码来源:FileManageController.php


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