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


PHP Storage::put方法代码示例

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


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

示例1: membersMapNorway

 /**
  * Norwegian map with municipalities where Alternativet is represented highlighted
  */
 public function membersMapNorway()
 {
     $data = "";
     if (!Storage::exists('members-norway-map.svg') || Storage::lastModified('members-norway-map.svg') <= time() - 60 * 60 * 24) {
         $svg = simplexml_load_file(base_path() . '/resources/svg/Norway_municipalities_2012_blank.svg');
         // Determine which municipalities there are members in
         $result = DB::select(DB::raw("\n              select postal_areas.municipality_code, count(*) as count\n              from users\n              left join postal_areas\n              on (users.postal_code = postal_areas.postal_code)\n              group by municipality_code"));
         $municipalities = [];
         foreach ($result as $row) {
             if ($row->municipality_code) {
                 $municipalities[] = $row->municipality_code;
             }
         }
         foreach ($svg->g as $county) {
             foreach ($county->path as $path) {
                 if (in_array($path['id'], $municipalities)) {
                     // There are members in this municipality
                     $path['style'] = 'fill:#0f0;fill-opacity:1;stroke:none';
                 } else {
                     $path['style'] = 'fill:#777;fill-opacity:1;stroke:none';
                 }
             }
         }
         $data = $svg->asXML();
         Storage::put('members-norway-map.svg', $data);
     }
     if (empty($data)) {
         $data = Storage::get('members-norway-map.svg');
     }
     return response($data)->header('Content-Type', 'image/svg+xml');
 }
开发者ID:partialternativet,项目名称:api,代码行数:34,代码来源:GraphicsController.php

示例2: putContent

 public function putContent(Request $request)
 {
     $contents = $request->all();
     $file = Storage::put('filter.txt', $contents['keywords']);
     flash()->success('修改成功');
     return redirect()->back();
 }
开发者ID:nutsdo,项目名称:mz-service,代码行数:7,代码来源:KeywordController.php

示例3: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //Get all reports where type = cucm_daily
     $reports = Report::where('type', 'cucm_daily')->get();
     //Get all configured CUCM clusters
     $clusters = $this->cluster->all();
     //Set timestamp for file names
     $timeStamp = Carbon::now('America/New_York')->toDateTimeString();
     //Create array to track attachments
     $attachments = [];
     //Loop reports
     foreach ($reports as $index => $report) {
         $attachments[$index] = $report->path . $report->name . '-' . $timeStamp . '.csv';
         //Persist report to disk
         Storage::put($attachments[$index], $report->csv_headers);
         //Loop each cluster and run the reports
         foreach ($clusters as $cluster) {
             $this->dispatch(new $report->job($cluster, $attachments[$index]));
         }
     }
     //Reports are done running, let's email to results
     $beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class);
     $beautymail->send('emails.cucmDailyReporting', [], function ($message) use($attachments) {
         //TODO: Create system for users to manage report subscriptions.
         $message->to(['martin_sloan@ao.uscourts.gov', 'kwang_chong@ao.uscourts.gov', 'aaron_dhiman@ao.uscourts.gov', 'minh_leung@ao.uscourts.gov'])->subject('CUCM Daily Report');
         //Add all reports to email
         foreach ($attachments as $report) {
             $message->attach(storage_path($report));
         }
     });
 }
开发者ID:sloan58,项目名称:uc-insight-esk,代码行数:36,代码来源:CallManagerReportingCommand.php

示例4: uploadPhoto

 public function uploadPhoto($userId, $filePath, $newImage = false)
 {
     $tmpFilePath = storage_path('app') . '/' . $userId . '.png';
     $tmpFilePathThumb = storage_path('app') . '/' . $userId . '-thumb.png';
     try {
         $this->correctImageRotation($filePath);
     } catch (\Exception $e) {
         \Log::error($e);
         //Continue on - this isnt that important
     }
     //Generate the thumbnail and larger image
     Image::make($filePath)->fit(500)->save($tmpFilePath);
     Image::make($filePath)->fit(200)->save($tmpFilePathThumb);
     if ($newImage) {
         $newFilename = \App::environment() . '/user-photo/' . md5($userId) . '-new.png';
         $newThumbFilename = \App::environment() . '/user-photo/' . md5($userId) . '-thumb-new.png';
     } else {
         $newFilename = \App::environment() . '/user-photo/' . md5($userId) . '.png';
         $newThumbFilename = \App::environment() . '/user-photo/' . md5($userId) . '-thumb.png';
     }
     Storage::put($newFilename, file_get_contents($tmpFilePath), 'public');
     Storage::put($newThumbFilename, file_get_contents($tmpFilePathThumb), 'public');
     \File::delete($tmpFilePath);
     \File::delete($tmpFilePathThumb);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:25,代码来源:UserImage.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $person = new User();
     $person->first_name = $request->input('first-name');
     $person->last_name = $request->input('last-name');
     $person->email = $request->input('work-email');
     $person->personal_email = $request->input('personal-email');
     $person->password = Hash::make(uniqid());
     $person->address1 = $request->input('address-one');
     $person->address2 = $request->input('address-two');
     $person->zip = $request->input('postcode');
     $person->city = $request->input('city');
     $person->state = $request->input('state');
     $person->country = $request->input('country');
     $person->dob = Carbon::createFromFormat('d/m/Y', $request->input('dob'))->toDateString();
     $person->work_telephone = $request->input('work-telephone');
     $person->personal_telephone = $request->input('personal-telephone');
     $person->gender = $request->input('gender');
     $person->save();
     // Placeholder face until one is submitted
     $path = 'people/' . $person->id . '/face.jpg';
     \Illuminate\Support\Facades\Storage::put($path, file_get_contents('http://api.adorable.io/avatar/400/' . md5($person->id . $person->email . Carbon::now()->getTimestamp()) . ''));
     $person->save();
     // Default job position
     $person->jobPositions()->attach(1, ['primary' => true]);
     // Default role
     $person->roles()->attach(1, ['primary' => true]);
     return redirect()->intended('/people/');
 }
开发者ID:TeenageHelpline,项目名称:Progress,代码行数:36,代码来源:UserController.php

示例6: upload

 public function upload()
 {
     $path = $this->folder . '/' . $this->newFileName;
     $content = file_get_contents($this->file->getRealPath());
     Storage::put($path, $content);
     return 'uploads/' . $path;
 }
开发者ID:ninjamonz,项目名称:laravel_catalog_example,代码行数:7,代码来源:UploadFile.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  * @throws ImageFailedException
  * @throws \BB\Exceptions\FormValidationException
  */
 public function store()
 {
     $data = \Request::only(['user_id', 'category', 'description', 'amount', 'expense_date', 'file']);
     $this->expenseValidator->validate($data);
     if (\Input::file('file')) {
         try {
             $filePath = \Input::file('file')->getRealPath();
             $ext = \Input::file('file')->guessClientExtension();
             $mimeType = \Input::file('file')->getMimeType();
             $newFilename = \App::environment() . '/expenses/' . str_random() . '.' . $ext;
             Storage::put($newFilename, file_get_contents($filePath), 'public');
             $data['file'] = $newFilename;
         } catch (\Exception $e) {
             \Log::error($e);
             throw new ImageFailedException($e->getMessage());
         }
     }
     //Reformat from d/m/y to YYYY-MM-DD
     $data['expense_date'] = Carbon::createFromFormat('j/n/y', $data['expense_date']);
     if ($data['user_id'] != \Auth::user()->id) {
         throw new \BB\Exceptions\FormValidationException('You can only submit expenses for yourself', new \Illuminate\Support\MessageBag(['general' => 'You can only submit expenses for yourself']));
     }
     $expense = $this->expenseRepository->create($data);
     event(new NewExpenseSubmitted($expense));
     return \Response::json($expense, 201);
 }
开发者ID:paters936,项目名称:BBMembershipSystem,代码行数:33,代码来源:ExpensesController.php

示例8: downloadFileInWindowsNT

 protected function downloadFileInWindowsNT(TFFile $file)
 {
     $client = new Client();
     try {
         $response = $client->get($file->source, ['verify' => false]);
     } catch (\Exception $e) {
         $error = 'TFDownloader: Downloading file failed, url is %s, msg is %s.';
         $error = sprintf($error, $file->source, $e->getMessage());
         Log::error($error);
         $file->state = 'error';
         $file->error = $error;
         $file->save();
         return;
     }
     if ($response->getStatusCode() == 200) {
         $location = 'file/' . $file->name;
         Storage::put($location, $response->getBody());
         $file->state = 'downloaded';
         $file->location = $location;
         $file->save();
         return;
     } else {
         $error = 'TFDownloader: Bad HTTP response code in downloading videos, url is %s, status code is %d.';
         $error = sprintf($error, $file->source, $response->getStatusCode());
         Log::error($error);
         $file->state = 'error';
         $file->error = $error;
         $file->save();
         return;
     }
 }
开发者ID:roslairy,项目名称:tumfetch,代码行数:31,代码来源:TFDownloader.php

示例9: updateEmail

 /**
  * Save new email
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function updateEmail(Request $request)
 {
     $this->validate($request, ['email' => 'required|email']);
     $email = $request->get("email");
     Storage::put('admin.txt', $email);
     return redirect("/");
 }
开发者ID:johnyhunt,项目名称:toopixel,代码行数:13,代码来源:AdminController.php

示例10: create

 /**
  * @param array $data
  * @return array
  */
 public function create(array $data)
 {
     $return = parent::create($data);
     if (!isset($return['error'])) {
         Storage::put($return->id . '.' . $return->extension, File::get($data['file']));
     }
     return $return;
 }
开发者ID:ao-lab,项目名称:laravel-manager,代码行数:12,代码来源:ArchiveService.php

示例11: handle

 /**
  * Execute the command.
  *
  */
 public function handle()
 {
     $newFile = File::create(['name' => 'verification_picture_' . $this->owner->user->username, 'extension' => 'jpg', 'stored_name' => str_random(64) . '.jpg', 'path' => 'verification_pictures']);
     $newFile->owner()->associate($this->owner);
     $newFile->save();
     Storage::put($newFile->path . '/' . $newFile->stored_name, base64_decode(str_replace(' ', '+', $this->picture)));
     return $newFile;
 }
开发者ID:wunderfactory,项目名称:weinform,代码行数:12,代码来源:CreateVerificationPicture.php

示例12: create

 public function create(UploadedFile $file, User $user)
 {
     $filename = sha1(rand(11111, 99999));
     $extension = $file->getClientOriginalExtension();
     Storage::put('images/' . $filename . '.' . $extension, file_get_contents($file->getRealPath()));
     $image = new Image(['user_id' => $user->id, 'filename' => $file->getClientOriginalName(), 'path' => $filename . '.' . $extension, 'mime_type' => $file->getMimeType(), 'location' => 'local', 'status' => Image::STATUS_PENDING]);
     $image->save();
     return $image;
 }
开发者ID:phpfour,项目名称:bangla-ocr,代码行数:9,代码来源:ImageRepository.php

示例13: createFile

 public function createFile(array $data)
 {
     $file = parent::create($data);
     if ($file) {
         if (Storage::put($data['name'] . '.' . $data['extension'], File::get($data['file']))) {
             return $file;
         }
     }
 }
开发者ID:riczat,项目名称:anglar,代码行数:9,代码来源:ProjectFileService.php

示例14: postFile

 public function postFile(Request $request)
 {
     $this->validate($request, ['file1' => 'required']);
     if ($request->ajax()) {
     } else {
         Storage::put(time() . '.jpg', file_get_contents($request->file('file1')));
     }
     Session::flash('success', ['Task was successful!']);
     return redirect()->action('SampleController@getFile');
 }
开发者ID:vakili722,项目名称:Software2,代码行数:10,代码来源:SampleController.php

示例15: putUpdate

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function putUpdate(Request $request)
 {
     $settings_array = $request->except('_token', '_method');
     if (!in_array('enable_recaptcha', $settings_array)) {
         $settings_array = $settings_array + ['enable_recaptcha' => 0];
     }
     $settings = json_encode($settings_array);
     Storage::put('settings.json', $settings);
     Cache::forever('settings', $settings_array);
     return redirect()->back()->withSuccess('updated');
 }
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:17,代码来源:SettingsController.php


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