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


PHP app\File类代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     // $v = Validator::make($request, [
     //       'type' => 'required',
     //       ]);
     // if ($v->fails())
     // {
     //     return redirect()->back()->withErrors($v->errors())
     //     						 ->withInput();
     // }else{
     //check for uploaded file and store it n public path
     $file = new File();
     $file->name = $request->get('name');
     $file->desc = $request->get('desc');
     $file->type = $request->get('type');
     if ($request->hasFile('file')) {
         $destination = 'files/';
         $filename = str_random(6) . "_" . $request->file('file')->getClientOriginalName();
         $request->file('file')->move($destination, $filename);
         $file->file = $filename;
     } else {
         $file->file = $request->get('file');
     }
     $file->save();
     // }
 }
开发者ID:raniafathy,项目名称:wavexpo,代码行数:32,代码来源:FilesController.php

示例2: IdentitasHandle

 public function IdentitasHandle($req, $id)
 {
     // PDF tidak di update / melalui form
     // Gagal mengupload file PDF
     // Sukses Mengupload DOkumen
     $temp_iden_pesan = ['error' => ['user' => 'Peringatan : File PDF tidak di atur dengan benar !', 'sistem' => 'Terjadi kesalahan upload File PDf '], 'succes' => ['store' => 'Sukses mengupload Dokumen PDF ', 'update' => 'Sukses mengupdate Dokumen PDF ']];
     $temp_file_pesan = ['error' => '', 'succes' => ''];
     // dd($req->all());
     $file = $req->file('gambar');
     if ($file and $file->getClientMimeType() == 'application/pdf') {
         // dd($file);
         $extension = $file->getClientOriginalExtension();
         $FileIdentity = File::where('dokumen_id', $id);
         // Update
         if (count($FileIdentity->get()->toArray())) {
             $this->result['identitas']['lama'] = $FileIdentity->get()->toArray();
             //delete file
             $data_for_update = ['mime' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'filename' => $file->getFilename() . '.' . $extension];
             if ($FileIdentity->update($update)) {
                 $this->result['identitas']['baru'] = $FileIdentity->get()->toArray();
                 $this->{$result}['pesan'] = $temp_iden_pesan['succes']['update'];
                 // proses storage
                 if (\Storage::delete($FileIdentity->get()->toArray()[0]['filename']) && \Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
                     $this->file_pesan['succes'] = $temp_file_pesan['succes'];
                     return true;
                 } else {
                     $this->file_pesan['error'] = $temp_file_pesan['error'];
                     return false;
                 }
                 return true;
             } else {
                 return false;
             }
         } else {
             // echo " new file";
             $new_dokument = new File();
             $new_dokument->dokumen_id = $id;
             $new_dokument->mime = $file->getClientMimeType();
             $new_dokument->original_filename = $file->getClientOriginalName();
             $new_dokument->filename = $file->getFilename() . '.' . $extension;
             //new identitas
             if ($new_dokument->save()) {
                 // new pdf
                 if (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
                     return true;
                 }
                 $this->{$result}['pesan'] = $temp_iden_pesan['succes']['store'];
                 return true;
             } else {
                 $this->{$result}['pesan'] = $temp_iden_pesan['error']['sistem'];
                 return false;
             }
         }
         // }
     } else {
         $this->{$result}['pesan'] = $temp_iden_pesan['error']['user'];
         return false;
     }
 }
开发者ID:acmadi,项目名称:sp2d,代码行数:59,代码来源:FileHandle.php

示例3: addNew

 public static function addNew($name, $file, $description = '', $patient_id = 0)
 {
     $new_file = new File();
     $new_file->name = $name;
     $new_file->description = $description;
     $new_file->patient_id = $patient_id;
     $new_file->save();
     $new_file->assignIcon($file->getClientOriginalExtension());
     $new_file->saveFile($file);
     return $new_file;
 }
开发者ID:VoodooPrawn,项目名称:finest,代码行数:11,代码来源:File.php

示例4: __construct

 /**
  * Initialize slide
  *
  * @param string $filePath Path of presentation file
  */
 public function __construct($filePath)
 {
     $file = new File($filePath);
     if ($file->load() === false) {
         echo 'Error! loading file .' . $filePath;
     }
     $this->contents = $file->getContents();
     $this->contents = explode(PHP_EOL . PHP_EOL . PHP_EOL, $this->contents);
     $this->slideCount = count($this->contents);
     $this->slideNumber = 0;
     $this->prev = false;
     $this->next = false;
     $this->parser = new Parsedown();
 }
开发者ID:deepsadhi,项目名称:presentation2.0,代码行数:19,代码来源:Slide.php

示例5: 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

示例6: showDashboard

 public function showDashboard(Request $req)
 {
     $leftmenu['dashboard'] = 'active';
     $files = File::with('client', 'technicien', 'laststatus.code.group', 'laststatus.technicien')->get();
     $files = CodeStatus::getThemAllLastStatus($files->toArray());
     return view('dashboard', ['leftmenu' => $leftmenu, 'files' => $files]);
 }
开发者ID:ninir007,项目名称:Ats,代码行数:7,代码来源:DashboardController.php

示例7: traverseInsideFolder

 public function traverseInsideFolder($folderPath = 'root', $token_id)
 {
     //        $token = User::find($this->usrId)->tokens->find($token_id);
     $root = File::where('token_id', $token_id)->where('path', $folderPath)->first();
     $file = $root->children()->get();
     return $file;
 }
开发者ID:noxfate,项目名称:gathercloud,代码行数:7,代码来源:FileMapping.php

示例8: 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

示例9: file

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function file($id)
 {
     $issue = Issue::where('id', '=', $id)->pluck('title');
     //dd($issue);
     $files = File::whereissue_id($id)->get();
     return view('public_journal.file', compact('files', 'issue'));
 }
开发者ID:polodev,项目名称:Bard-Ftfl-Laravel-Project,代码行数:13,代码来源:publicJournalController.php

示例10: setMntImgAttribute

 public function setMntImgAttribute($file)
 {
     $name = $this->sanear_string(utf8_decode($this->MNT_NOMBRE));
     $this->attributes['MNT_IMG'] = 'image_' . str_replace(' ', '', $name) . '.jpg';
     $nombre = 'image_' . str_replace(' ', '', $name) . '.jpg';
     \Storage::disk('local')->put($nombre, \File::get($file));
 }
开发者ID:jfcanchignia92,项目名称:sgabrielapp,代码行数:7,代码来源:Ministerio.php

示例11: checkDirPermission

 public static function checkDirPermission()
 {
     $dirPath = storage_path('app/' . self::$dir);
     if (!Filesystem::exists($dirPath)) {
         Filesystem::makeDirectory($dirPath, 0774);
     }
 }
开发者ID:faltastic,项目名称:Syria-On-The-Move,代码行数:7,代码来源:File.php

示例12: sendNotificationEmail

 public function sendNotificationEmail(Group $group, User $user)
 {
     if ($user->verified == 1) {
         // Establish timestamp for notifications from membership data (when was an email sent for the last time?)
         $membership = \App\Membership::where('user_id', '=', $user->id)->where('group_id', "=", $group->id)->firstOrFail();
         $last_notification = $membership->notified_at;
         // find unread discussions since timestamp
         $discussions = QueryHelper::getUnreadDiscussionsSince($user->id, $group->id, $membership->notified_at);
         // find new files since timestamp
         $files = \App\File::where('updated_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->get();
         // find new members since timestamp
         $users = QueryHelper::getNewMembersSince($user->id, $group->id, $membership->notified_at);
         // find future actions until next 2 weeks, this is curently hardcoded... TODO use the mail sending interval to determine stop date
         $actions = \App\Action::where('start', '>', Carbon::now())->where('stop', '<', Carbon::now()->addWeek()->addWeek())->where('group_id', "=", $group->id)->orderBy('start')->get();
         // we only trigger mail sending if a new action has been **created** since last notfication email.
         // BUT we will send actions for the next two weeks in all cases, IF a mail must be sent
         $actions_count = \App\Action::where('created_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->count();
         // in all cases update timestamp
         $membership->notified_at = Carbon::now();
         $membership->save();
         // if we have anything, build the message and send
         // removed that : or count($users) > 0
         // because we don't want to be notified just because there is a new member
         if (count($discussions) > 0 or count($files) > 0 or $actions_count > 0) {
             Mail::send('emails.notification', ['user' => $user, 'group' => $group, 'membership' => $membership, 'discussions' => $discussions, 'files' => $files, 'users' => $users, 'actions' => $actions, 'last_notification' => $last_notification], function ($message) use($user, $group) {
                 $message->from(env('MAIL_NOREPLY', 'noreply@example.com'), env('APP_NAME', 'Laravel'))->to($user->email)->subject('[' . env('APP_NAME') . '] ' . trans('messages.news_from_group_email_subject') . ' "' . $group->name . '"');
             });
             return true;
         }
         return false;
     }
 }
开发者ID:philippejadin,项目名称:Mobilizator,代码行数:32,代码来源:AppMailer.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     //echo "string"; exit();
     $v = Validator::make(Request::all(), ['name' => 'required|max:50|unique:exhibitors']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $exhibition = new Exhibition();
         $exhibition->name = Request::get('name');
         $exhibition->desc = Request::get('desc');
         $exhibition->save();
         // File Storage
         $file = new File();
         $file->name = Request::get('filename');
         $file->desc = Request::get('filedesc');
         $file->type = Request::get('filetype');
         if (Request::hasFile('file')) {
             $destination = 'files/';
             $filename = str_random(6) . "_" . Request::file('file')->getClientOriginalName();
             Request::file('file')->move($destination, $filename);
             $file->file = $filename;
         } else {
             $file->file = Request::get('file');
         }
         $file->save();
         $userfile = new ExhibitionFile();
         $userfile->exhibition_id = $exhibition->id;
         $userfile->file_id = $file->id;
         $userfile->save();
         return redirect('exhibitions');
     }
 }
开发者ID:rababZein,项目名称:RababDeveloper,代码行数:38,代码来源:ExhibitionsController.php

示例14: setImgUrlAttribute

 public function setImgUrlAttribute($img_url)
 {
     if (!empty($img_url)) {
         $name = Carbon::now()->second . $img_url->getClientOriginalName();
         $this->attributes['img_url'] = $name;
         \Storage::disk('local')->put($name, \File::get($img_url));
     }
 }
开发者ID:angelsalazar,项目名称:plazaapp,代码行数:8,代码来源:Post.php

示例15: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $file = File::findOrFail($id);
     unlink($_SERVER['DOCUMENT_ROOT'] . $file->url);
     $file->delete();
     return 1;
 }
开发者ID:urbanix,项目名称:contract-payments-demo,代码行数:14,代码来源:FileController.php


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