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


PHP Input::hasfile方法代码示例

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


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

示例1: acttdb

 public function acttdb()
 {
     $data = array();
     $camino = public_path('img/tdb/');
     $id = Input::get('id');
     $tdb = TDB::find($id);
     $nombre = Input::get('nombre');
     $imagen = Input::file('imagen');
     $cambio = false;
     if ($tdb->nombre == $nombre) {
         $cambio = false;
     } else {
         $cambio = true;
     }
     if (Input::hasfile('imagen')) {
         File::delete($camino . $tdb->id . '.' . $tdb->extension);
         $ext = $imagen->getClientOriginalExtension();
         $imagen->move($camino, $id . '.' . $ext);
         $tdb->extension = $ext;
         $data['imagen'] = asset('/img/tdb/' . $id . '.' . $ext);
     } else {
         $data['imagen'] = '';
     }
     $tdb->nombre = $nombre;
     $query = $tdb->save();
     if ($cambio != false) {
         $data['nombre'] = $nombre;
     } else {
         $data['nombre'] = '';
     }
     return Response::json($data);
 }
开发者ID:jofranmi,项目名称:beachaddiction,代码行数:32,代码来源:ajax.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->except('_token');
     $product = new Product($input);
     $product->category_id = Input::get('category');
     Auth::user()->products()->save($product);
     if (Input::hasfile('image')) {
         $file = Input::file('image');
         $file->move('upload', $product->id . '.png');
     }
     Session::flash('success', 'Product uploaded successfully.');
     return redirect('/product');
 }
开发者ID:kaungsoe,项目名称:ecomproject,代码行数:19,代码来源:ProductController.php

示例3: save

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function save()
 {
     $artikel = new artikel();
     $artikel->id_user = Auth::user()->id;
     $artikel->title = Input::get('title');
     $artikel->content = Input::get('content');
     $artikel->slug = str_slug(input::get('title'));
     $artikel->id_artikel = Input::get('id_artikel');
     if (Input::hasfile('pict')) {
         $pict = date("YmdHis") . uniqid() . "." . Input::file('pict')->getClientOriginalExtension();
         Input::file('pict')->move(storage_path(), $pict);
         $artikel->pict = $pict;
     }
     $artikel->save();
     return redirect(url('all_artikel'));
 }
开发者ID:rzdannisa,项目名称:blog_pkl,代码行数:21,代码来源:ArtikelController.php

示例4: update

 public function update($id)
 {
     $Category = Category::find($id);
     $input = Input::all();
     $rules = array('image' => 'image');
     $niceNames = array('image' => 'image');
     $validator = Validator::make($input, $rules);
     $validator->setAttributeNames($niceNames);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
     } else {
         if (Input::has('show')) {
             $Category->show = Input::get('show');
         }
         if (Input::has('ordering')) {
             $Category->ordering = Input::get('ordering');
         }
         if (Input::has('status')) {
             $Category->status = Input::get('status');
         }
         if (Input::has('title')) {
             $Category->title = Input::get('title');
         }
         if (Input::has('favor')) {
             $Category->favor = Input::get('favor');
         }
         if (Input::has('level2')) {
             if (Input::get('level2') != '') {
                 $Category->parent_id = Input::get('level2');
             } else {
                 $Category->parent_id = null;
             }
         }
         if (Input::hasfile('image')) {
             $file = Input::file('image');
             $destinationPath = 'uploads/category/';
             $filename = $file->getClientOriginalName();
             Input::file('image')->move($destinationPath, $filename);
             $ext = substr($filename, strrpos($filename, "."));
             $newFileName = basename($filename, $ext) . "_" . $Category->id . "_" . date("Ymdhis") . $ext;
             rename($destinationPath . $filename, $destinationPath . $newFileName);
             Category::where('id', $Category->id)->update(['image_path' => $destinationPath . $newFileName]);
         }
         $Category->save();
         if (Input::hasfile('image')) {
             return Response::json(['success' => true, 'message' => 'Category has been updated!', 'file' => asset($destinationPath . $newFileName)]);
         } else {
             return Response::json(['success' => true, 'message' => 'Category has been updated!']);
         }
     }
 }
开发者ID:keung725,项目名称:shop,代码行数:51,代码来源:CategoryController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $post = posts::find(Input::get('id'));
     $post->idpengguna = Auth::user()->id;
     $post->judul = Input::get('judul');
     $post->isi = Input::get('isi');
     $post->tag = Input::get('tag');
     $post->slug = str_slug(input::get('judul'));
     if (Input::hasfile('sampul')) {
         $sampul = date("YmdHis") . uniqid() . "." . Input::file('sampul')->getClientOriginalExtension();
         Input::file('sampul')->move(storage_path(), $sampul);
         $post->sampul = $sampul;
     }
     $post->save();
     return redirect(url('artikel'));
 }
开发者ID:Nadiannisaqilah,项目名称:blogg,代码行数:22,代码来源:ArtikelController.php

示例6: kirimcover

 public function kirimcover()
 {
     $post = new Buku();
     // $post->idpengguna = Auth::user()->id;
     $post->title = Input::get('title');
     $post->description = Input::get('description');
     $post->slug = str_slug(input::get('title'));
     if (Input::hasfile('cover')) {
         $cover = date("YmdHis") . uniqid() . "." . Input::file('cover')->getClientOriginalExtension();
         Input::file('cover')->move(storage_path(), $cover);
         $post->cover = $cover;
     }
     $post->save();
     return redirect(url('cover'));
 }
开发者ID:KUHAKU10,项目名称:O-MILD,代码行数:15,代码来源:MainController.php

示例7: updateEvent

 /**
  * Update an existing event's info in the events table.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function updateEvent(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|max:40', 'venue' => 'required|max:30', 'city' => 'required|max:30', 'price' => 'required|numeric', 'information' => 'required|max:255', 'description' => 'required', 'capacity' => 'required|numeric', 'date' => 'required|date', 'image' => 'image']);
     $name = $request->input('name');
     $venue = $request->input('venue');
     $city = $request->input('city');
     $price = $request->input('price');
     $information = $request->input('information');
     $description = $request->input('description');
     $capacity = $request->input('capacity');
     $date = $request->input('date');
     $image = $request->input('image');
     if (Input::hasfile('image')) {
         Event::where('id', $id)->update(['name' => $name, 'venue' => $venue, 'city' => $city, 'price' => $price, 'information' => $information, 'description' => $description, 'capacity' => $capacity, 'date' => $date, 'image' => $image]);
         $imgName = $id . "." . Input::file('image')->getClientOriginalExtension();
         //gets the event ID and concat on the imaage file extension that was uploaded
         Input::file('image')->move(__DIR__ . '/../../../public/img/event_images', $imgName);
         //moves the uploaded image from the tmp directory to a premanant one (/public/img/event_images) and renames it to <eventID>.<fileExt>
         $image = Event::where('id', $id)->first();
         //returns the same event as the one being updated
         $image->image = $imgName;
         //adds the image name from above to the image column of the latest event
         $image->save();
         //saves the above action
     } else {
         Event::where('id', $id)->update(['name' => $name, 'venue' => $venue, 'city' => $city, 'price' => $price, 'information' => $information, 'description' => $description, 'capacity' => $capacity, 'date' => $date]);
     }
     return redirect('admin');
 }
开发者ID:xRokco,项目名称:websysproject,代码行数:36,代码来源:AdminController.php


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