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


PHP Request::file方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //obtenemos el campo file definido en el formulario
     $file1 = $request->file('foto1');
     $file2 = $request->file('foto2');
     $file3 = $request->file('foto3');
     //        $input  = array('image' => $file1);
     //        $reglas = array('image' => 'mimes:jpeg,png');
     //        $validacion = Validator::make($input,  $reglas);
     //        if ($validacion->fails())
     //        {
     //            \Session::flash('flash_message', 'Una de las imagenes no es correcta');
     //        }
     //obtenemos el nombre del archivo
     $nombre1 = $file1->getClientOriginalName();
     $nombre2 = $file2->getClientOriginalName();
     $nombre3 = $file3->getClientOriginalName();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre1, \File::get($file1));
     \Storage::disk('local')->put($nombre2, \File::get($file2));
     \Storage::disk('local')->put($nombre3, \File::get($file3));
     $persona = Persona::find($request->persona_id);
     $persona->fill($request->all());
     $persona->foto1 = $request->persona_id . '|' . $nombre1;
     $persona->foto2 = $request->persona_id . '|' . $nombre2;
     $persona->foto3 = $request->persona_id . '|' . $nombre3;
     $persona->save();
     return view('new');
 }
开发者ID:javparra,项目名称:inscripcion,代码行数:34,代码来源:InscripcionController.php

示例2: store

 /**
  * 上传处理控制器
  */
 public function store(Request $request)
 {
     //return  $request->file('Filedata')->getClientOriginalExtension();  jpg
     if ($request->hasFile('Filedata') and $request->file('Filedata')->isValid()) {
         $allow = array('image/jpeg', 'image/png', 'image/gif');
         $mine = $request->file('Filedata')->getMimeType();
         if (!in_array($mine, $allow)) {
             $result['status'] = 0;
             $result['info'] = '文件类型错误,只能上传图片';
             return $result;
         }
         //文件大小判断
         $max_size = 1024 * 1024 * 3;
         $size = $request->file('Filedata')->getClientSize();
         if ($size > $max_size) {
             $result['status'] = 0;
             $result['info'] = '文件大小不能超过3M';
             return $result;
         }
         //上传文件夹,如果不存在,建立文件夹
         $date = date("Y_m");
         $path = getcwd() . '/uploads/image/' . $date;
         if (!is_dir($path)) {
             mkdir($path);
         }
         //生成新文件名
         $extension = $request->file('Filedata')->getClientOriginalExtension();
         $file_name = md5(time() . rand(0, 9999999)) . '.' . $extension;
         $request->file('Filedata')->move($path, $file_name);
         //返回新文件名
         $result['status'] = 1;
         $result['info'] = '/uploads/image/' . $date . '/' . $file_name;
         return $result;
     }
 }
开发者ID:noikiy,项目名称:wfhshop_wechat_laravel,代码行数:38,代码来源:UploadController.php

示例3: postIndex

 public function postIndex(Request $request)
 {
     $user = $request->user();
     if (UserProfile::where('user_id', $user->id)->count()) {
         $profile = UserProfile::where('user_id', $user->id)->first();
         $profile_picture = $profile->profile_pic;
         $proof = $profile->photo_id_proof;
     } else {
         $profile = new UserProfile();
         $profile_picture = NULL;
         $proof = NULL;
     }
     if ($request->hasFile('profile_picture')) {
         $profile_picture = $user->id . '_' . $request->file('profile_picture')->getClientOriginalName();
         $request->file('profile_picture')->move('uploads/profile_pics/', $profile_picture);
     }
     if ($request->hasFile('proof')) {
         $proof = $user->id . '_' . $request->file('proof')->getClientOriginalName();
         $request->file('proof')->move('uploads/proof/', $proof);
     }
     $profile->user_id = $user->id;
     $profile->profile_pic = $profile_picture;
     $profile->designation = $request->designation;
     $profile->address = $request->address;
     $profile->city = $request->city;
     $profile->state = $request->state;
     $profile->country = $request->country;
     $profile->photo_id_proof = $proof;
     $profile->save();
     return redirect('profile');
 }
开发者ID:keshavkatwe,项目名称:IgnitoOpenHouse,代码行数:31,代码来源:ProfileController.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // ajax upload
     if ($request->ajax()) {
         // check upload image
         if (!$request->hasFile('uploadImg')) {
             // return json data with error message noImgUpload
             return response()->json(['error' => 'noUploadImg']);
         } else {
             if (!$this->checkImage($request->file('uploadImg'))) {
                 // return json data with error message wrongImgType
                 return response()->json(['error' => 'wrongImgType']);
             } else {
                 if (filesize($request->file('uploadImg')->getPathname()) > 2 * 2 ** 20) {
                     return response()->json(['error' => 'file size is bigger than 2MB']);
                 }
             }
         }
     } else {
         // check has uploadImg or not
         if ($request->hasFile('uploadImg')) {
             // check image content
             if (!$this->checkImage($request->file('uploadImg'))) {
                 // check fail, redirect back with errors
                 return back()->withInput($request->except('uploadImg'))->withErrors('小搗蛋 大頭貼只能選圖片唷:)');
             }
         }
     }
     // pass all check
     return $next($request);
 }
开发者ID:weiyeu,项目名称:laravel_date,代码行数:38,代码来源:CheckUploadImg.php

示例5: uploadpcount

 public function uploadpcount(Request $request)
 {
     $destinationPath = storage_path() . '/uploads/pcount/';
     $fileName = $request->file('data')->getClientOriginalName();
     $request->file('data')->move($destinationPath, $fileName);
     return response()->json(array('msg' => 'file uploaded', 'status' => 0));
 }
开发者ID:renciebautista,项目名称:pcount,代码行数:7,代码来源:UploadController.php

示例6: postUpload

 public function postUpload(Request $req)
 {
     $response = array();
     if ($req->file('excelF')) {
         $file = $req->file('excelF');
         $extension = $file->getClientOriginalExtension();
         $filename = $file->getClientOriginalName();
         /*periksa extensi file */
         if ('xlsx' !== $extension) {
             $response['code'] = 404;
             $response['msg'] = "File berextensi {$extension} dengan nama {$filename}, file Seharusnya Berupa Excel";
             // $response['msg']="File Anda   $file->getClientOriginalName(), Pastikan File yang Anda upload sesuai dengan format ";
             return $response;
             // return $response;
         } elseif (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
             // simpan kedadalam table
             $entry = new Fileentry();
             $entry->mime = $file->getClientMimeType();
             $entry->original_filename = $file->getClientOriginalName();
             $entry->filename = $file->getFilename() . '.' . $extension;
             $entry->save();
             $response['code'] = 200;
             $response['msg'] = "File  {$entry->original_filename} Telah disimpan";
             return $response;
         }
     }
     $response['code'] = 404;
     $response['msg'] = "Gagal Upload File !!!";
     return json_encode($response);
     // echo '{"TEST1": 454535353,"TEST2": "test2"}';
 }
开发者ID:acmadi,项目名称:integrasi,代码行数:31,代码来源:BidangControllerBackup02.php

示例7: saveImage

 /**
  * @param Request $request
  * @return string
  */
 protected function saveImage(Request $request)
 {
     $ext = $request->file('image')->getClientOriginalExtension();
     $imageName = str_slug($request->input('name')) . '.' . $ext;
     $request->file('image')->move('images/products/', $imageName);
     return $imageName;
 }
开发者ID:fransiskusbenny,项目名称:larashop,代码行数:11,代码来源:ProductControler.php

示例8: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     // validation
     $v = \Validator::make($request->all(), ['url_file' => 'required|max:5000', 'place_id' => 'required|numeric', 'type_print' => 'required|numeric']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     }
     // generate code print
     $code = app('App\\Repositories\\PrintList\\PrintListRepository')->_get_code();
     $file_name = "";
     $old_name_file = "";
     // section untuk file
     if ($request->hasFile('url_file')) {
         $file_extensi = $request->file('url_file')->getClientOriginalExtension();
         $file_name = $code . "." . $file_extensi;
         $old_name_file = $request->file('url_file')->getClientOriginalName();
         if ($file_extensi == "doc" || $file_extensi == "docx" || $file_extensi == "pdf" || $file_extensi == "xls" || $file_extensi == "xlsx" || $file_extensi == "ods" || $file_extensi == "odt") {
             $request->file('url_file')->move(base_path() . '/public/file', $code . "." . $file_extensi);
         } else {
             return redirect()->back()->withErrors('Sorry the file must be with extension doc, docx or pdf');
         }
     } else {
         return redirect()->back()->withErrors($v->errors())->withInput();
     }
     // saving data
     app('App\\Repositories\\PrintList\\PrintListRepository')->savePrintList($request->all(), $this->user_id, $code, $file_name, $old_name_file);
     return redirect('konfirm/' . $code);
 }
开发者ID:jojoarianto,项目名称:sprint,代码行数:33,代码来源:PrintController.php

示例9: postStore

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postStore(Request $request)
 {
     $input = $request->all();
     //		return ($input['Administrative']);
     DB::beginTransaction();
     $apps = Application::create($input['REGISTRANT']);
     $input['Administrative']['registrant_id'] = $apps->id;
     $input['Technical']['registrant_id'] = $apps->id;
     if ($request->hasFile("image1")) {
         $destinationPath = 'uploads/a/';
         $fileName = time() . "-" . $request->file('image1')->getClientOriginalName();
         $request->file('image1')->move($destinationPath, $fileName);
         $input['Administrative']['image'] = $fileName;
     }
     if ($request->hasFile('image2')) {
         $destinationPath = 'uploads/t/';
         $fileName = time() . "-" . $request->file('image2')->getClientOriginalName();
         $request->file('image2')->move($destinationPath, $fileName);
         $input['Technical']['image'] = $fileName;
     }
     return 1;
     Administrative::create($input['Administrative']);
     Technical::create($input['Technical']);
     DB::commit();
     return redirect()->back()->withSuccess('Application Submitted Successfully');
 }
开发者ID:bappa2du,项目名称:laravel_admin_lte,代码行数:31,代码来源:WebController.php

示例10: store

 public function store(Request $request)
 {
     $uniq = md5(uniqid(time(), true));
     if (!$request->file('image')) {
         return Redirect::back();
     }
     if ($request->hasFile('image')) {
         $image = $request->file('image');
         $ext = $image->getClientOriginalExtension();
         $name_image = $image->getClientOriginalName();
         $image->move('img/temp/', $uniq . '.' . $ext);
         $image_final = 'img/temp/' . $uniq . '.' . $ext;
         $int_image = Image::make($image_final);
         $int_image->resize(568, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $int_image->save($image_final);
         Session::put('modal', 'true');
     } else {
         $image_final = $request->get('img_bckp');
     }
     Session::put('img', $image_final);
     Session::put('img_name', $name_image);
     Session::put('img_hash_name', $uniq . "." . $ext);
     return Redirect::back();
 }
开发者ID:sochea09,项目名称:laravel-blog,代码行数:26,代码来源:Media.php

示例11: store

 /**
  * Update the users profile
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = User::find($request->input('user_id'));
     $user->name = $request->input('name');
     $user->email = $request->input('email');
     $user->username = $request->input('username');
     if ($request->input('password') != '') {
         $user->password = bcrypt($request->input('password'));
     }
     $user->update();
     $company = Company::where('user_id', $request->input('user_id'))->first();
     $company->name = $request->input('company_name');
     $company->description = $request->input('company_description');
     $company->phone = $request->input('company_phone');
     $company->email = $request->input('company_email');
     $company->address1 = $request->input('company_address');
     $company->address2 = $request->input('company_address2');
     $company->city = $request->input('company_city');
     $company->postcode = $request->input('company_postcode');
     if ($request->hasFile('logo')) {
         $file = $request->file('logo');
         $name = Str::random(25) . '.' . $file->getClientOriginalExtension();
         $image = Image::make($request->file('logo')->getRealPath())->resize(210, 113, function ($constraint) {
             $constraint->aspectRatio();
         });
         $image->save(public_path() . '/uploads/' . $name);
         $company->logo = $name;
     }
     $company->update();
     flash()->success('Success', 'Profile updated');
     return back();
 }
开发者ID:wyrover,项目名称:applications,代码行数:39,代码来源:ProfileController.php

示例12: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     //读取内容
     $photo = $request->file('photo');
     $extension = strtolower($photo->getClientOriginalExtension());
     $input = $request->all();
     //save image
     //get imageurl
     //save model
     if ($request->file('photo')->isValid()) {
         $name = md5(microtime() . $input['name']) . '.' . $extension;
         $path = 'img/goods';
         $request->file('photo')->move($path, $name);
         $image_url = $path . '/' . $name;
         $goods = new Goods();
         $goods->name = $input['name'];
         $goods->description = $input['description'];
         $goods->user_id = Auth::User()->id;
         $goods->type = $input['type'];
         $goods->price = $input['price'];
         $goods->status = 0;
         $goods->image_url = $image_url;
         $goods->save();
         return redirect('/goods/' . $goods->id . '/detail')->with('message', 'Information successfully recorded');
     }
 }
开发者ID:zw1003855799,项目名称:SE-Service-Exchange,代码行数:31,代码来源:GoodsController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data['arquivo'] = $request->file('file');
     $data['extension'] = $request->file('file')->getClientOriginalExtension();
     $data['name'] = $request->name;
     $this->service->createFile($data);
 }
开发者ID:igorfaria06,项目名称:laravel,代码行数:13,代码来源:ProjetoArquivosController.php

示例14: importdata

 public function importdata(Request $request)
 {
     $results = null;
     $file = $request->file('exelimport');
     $request->file('exelimport')->move(storage_path() . '/public/import/', 'import.xlsx');
     $retdate = Excel::load(storage_path('/public/import/import.xlsx'), function ($reader) {
         $results = $reader->setDateColumns(array('startdate', 'enddate'))->get();
         $data = array();
         $dataupdate = array();
         $datauser = array();
         //            $results = $reader->get();
         $ret = $results->toArray();
         $empidtoStatus = "123";
         foreach ($ret as $index => $value) {
             //                var_dump($value["enddate"]);
             $EMP_ID = $value["empid"];
             $userinfo = DB::table('TBL_EMPLOYEE_INFO')->where('EMP_ID', $EMP_ID)->get();
             $user = DB::table('TBL_USER')->where('EMP_ID', $EMP_ID)->get();
             $TBL_EMP_PENSION = DB::table('TBL_EMP_PENSION')->where('EMP_ID', $EMP_ID)->get();
             //                $StatusID = $value["user_status_id"];
             if ($TBL_EMP_PENSION == null) {
                 if ($userinfo == null) {
                     //                    var_dump($value["enddate"]);
                     $dateS = new Date($value["startdate"]);
                     $dateStart = date("d/m/Y", strtotime($dateS));
                     $dateE = new Date($value["enddate"]);
                     $dateEnd = date("d/m/Y", strtotime($dateE));
                     array_push($data, array('EMP_ID' => $value["empid"], 'PREFIX' => $value["prefix"], 'FULL_NAME' => $value["fullname"], 'ENG_NAME' => $value["engname"], 'FIRST_NAME' => $value["firstname"], 'LAST_NAME' => $value["lastname"], 'PRIORITY' => $value["priority"], 'JOB_ID' => $value["jobid"], 'JOB_DESC_SHT' => $value["jobdescsht"], 'JOB_DESC' => $value["jobdesc"], 'PER_ID' => $value["perid"], 'START_DATE' => $dateStart, 'END_DATE' => $dateEnd, 'COST_CENTER' => $value["costcenter"], 'C_LEVEL' => $value["clevel"], 'POST_ID' => $value["posid"], 'POS_DESC' => $value["posdesc"], 'ORG_ID' => $value["orgid"], 'ENG_FIRST_NAME' => $value["engfirstname"], 'ENG_LAST_NAME' => $value["englastname"], 'BIRTH_DATE' => $value["birthdate"], 'ORG_DESC' => $value["orgdesc"], 'PATH_ID' => $value["pathid"], 'DEP_ID' => $value["depid"], 'DIV_ID' => $value["divid"], 'SEC_ID' => $value["secid"], 'PART_ID' => $value["partid"], 'PARTH_SHT' => $value["pathsht"], 'DEP_SHT' => $value["depsht"], 'DIV_SHT' => $value["divsht"], 'SEC_SHT' => $value["secsht"], 'PATH_SHT' => $value["partsht"], 'PARTH_LNG' => $value["pathlng"], 'DEP_LNG' => $value["deplng"], 'DIV_LNG' => $value["divlng"], 'SEC_LNG' => $value["seclng"], 'PART_LNG' => $value["partlng"]));
                 } else {
                     $dateS = new Date($value["startdate"]);
                     $dateStart = date("d/m/Y", strtotime($dateS));
                     $dateE = new Date($value["enddate"]);
                     $dateEnd = date("d/m/Y", strtotime($dateE));
                     $dataupdate = array('EMP_ID' => $value["empid"], 'PREFIX' => $value["prefix"], 'FULL_NAME' => $value["fullname"], 'ENG_NAME' => $value["engname"], 'FIRST_NAME' => $value["firstname"], 'LAST_NAME' => $value["lastname"], 'PRIORITY' => $value["priority"], 'JOB_ID' => $value["jobid"], 'JOB_DESC_SHT' => $value["jobdescsht"], 'JOB_DESC' => $value["jobdesc"], 'PER_ID' => $value["perid"], 'START_DATE' => $dateStart, 'END_DATE' => $dateEnd, 'COST_CENTER' => $value["costcenter"], 'C_LEVEL' => $value["clevel"], 'POST_ID' => $value["posid"], 'POS_DESC' => $value["posdesc"], 'ORG_ID' => $value["orgid"], 'ENG_FIRST_NAME' => $value["engfirstname"], 'ENG_LAST_NAME' => $value["englastname"], 'BIRTH_DATE' => $value["birthdate"], 'ORG_DESC' => $value["orgdesc"], 'PATH_ID' => $value["pathid"], 'DEP_ID' => $value["depid"], 'DIV_ID' => $value["divid"], 'SEC_ID' => $value["secid"], 'PART_ID' => $value["partid"], 'PARTH_SHT' => $value["pathsht"], 'DEP_SHT' => $value["depsht"], 'DIV_SHT' => $value["divsht"], 'SEC_SHT' => $value["secsht"], 'PATH_SHT' => $value["partsht"], 'PARTH_LNG' => $value["pathlng"], 'DEP_LNG' => $value["deplng"], 'DIV_LNG' => $value["divlng"], 'SEC_LNG' => $value["seclng"], 'PART_LNG' => $value["partlng"]);
                     DB::table('TBL_EMPLOYEE_INFO')->where('EMP_ID', "=", $value["empid"])->update($dataupdate);
                 }
                 if ($user == null) {
                     $date = new Date();
                     $pri = $userinfo = DB::table('TBL_PRIVILEGE')->where('USER_PRIVILEGE_ID', 2)->get();
                     $datedata = $value["birthdate"];
                     $newDate = substr($datedata, -2) . substr($datedata, -4, 2) . ((int) substr($datedata, -8, 4) + 543);
                     $MEASecEncoe = new \Security();
                     $ecPass = $MEASecEncoe->encrypt($newDate, "#Gm2014\$06\$30@97");
                     //$ecPass = exec("cmd /c md5.bat -e ".$newDate." 2>&1");
                     //$ecPass = explode(':',$ecPass)[1];
                     $datedefault = new Date("9999-12-31 00:00:00.000");
                     $admin = 'Administrator';
                     $user_id = '2';
                     array_push($datauser, array('EMP_ID' => $EMP_ID, 'USERNAME' => $EMP_ID, 'PASSWORD' => $ecPass, 'PASSWORD_EXPIRE_DATE' => $datedefault, 'CREATE_DATE' => $date, 'CREATE_BY' => $admin, 'LAST_MODIFY_DATE' => $date, 'USER_PRIVILEGE_ID' => $user_id, 'ACCESS_PERMISSIONS' => $pri[0]->ACCESS_PERMISSIONS, 'USER_STATUS_ID' => 13, 'FIRST_LOGIN_FLAG' => 0, 'EMAIL_NOTIFY_FLAG' => 1));
                 }
             }
             $empidtoStatus .= "," . $EMP_ID;
         }
         DB::table('TBL_EMPLOYEE_INFO')->insert($data);
         DB::table('TBL_USER')->insert($datauser);
         $sql = "UPDATE TBL_USER SET user_status_id= 14  WHERE EMP_ID NOT IN (" . $empidtoStatus . ")";
         DB::update(DB::raw($sql));
     });
     return response()->json(array('success' => true, 'html' => $retdate));
 }
开发者ID:FreelanceDArkman,项目名称:MEA,代码行数:60,代码来源:UserManageController.php

示例15: new_post

 public function new_post(Request $request)
 {
     if ($request->isMethod('post')) {
         $rules = array('title' => 'required', 'description' => 'required');
         $validator = Validator::make($request->all(), $rules);
         if ($validator->fails()) {
             return Redirect('new_post')->withErrors($validator)->withInput();
         } else {
             $blog = new Blog();
             $blog->title = $request->input('title');
             $blog->description = $request->input('description');
             $blog->category = $request->input('category');
             if ($request->hasFile('photo')) {
                 $blog->photo = $request->file('photo')->getClientOriginalName();
                 $request->file('photo')->move(public_path() . '/user_file/', $blog->photo);
             }
             $blog->save();
             if ($blog->id) {
                 Session::flash('success_msg', 'You have published new blog successfully');
                 return redirect('new_post');
             }
         }
     }
     $data['categories'] = Category::all();
     return view('blog.new_post', $data);
 }
开发者ID:raselahmed01,项目名称:laravelrasel,代码行数:26,代码来源:BlogController.php


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