本文整理汇总了PHP中Illuminate\Support\Facades\Input::file方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::file方法的具体用法?PHP Input::file怎么用?PHP Input::file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Upload the file and store
* the file path in the DB.
*/
public function store()
{
// Rules
$rules = array('name' => 'required', 'file' => 'required|max:20000');
$messages = array('max' => 'Please make sure the file size is not larger then 20MB');
// Create validation
$validator = Validator::make(Input::all(), $rules, $messages);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$directory = "uploads/files/";
// Before anything let's make sure a file was uploaded
if (Input::hasFile('file') && Request::file('file')->isValid()) {
$current_file = Input::file('file');
$filename = Auth::id() . '_' . $current_file->getClientOriginalName();
$current_file->move($directory, $filename);
$file = new Upload();
$file->user_id = Auth::id();
$file->project_id = Input::get('project_id');
$file->name = Input::get('name');
$file->path = $directory . $filename;
$file->save();
return Redirect::back();
}
$upload = new Upload();
$upload->user_id = Auth::id();
$upload->project_id = Input::get('project_id');
$upload->name = Input::get('name');
$upload->path = $directory . $filename;
$upload->save();
return Redirect::back();
}
示例2: postImport
public function postImport($id)
{
$report = \App\Models\Report::find($id);
if (Input::hasFile('file')) {
$file = Input::file('file');
$filename = $file->getClientOriginalName();
$destinationPath = public_path() . '/uploads/';
Input::file('file')->move($destinationPath, $filename);
$handle = fopen(public_path() . '/uploads/' . $filename, "r");
if ($handle !== FALSE) {
while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) {
$depreciation = new \App\Models\Depreciation();
$name = iconv("Windows-1251", "utf-8", $data[0]);
$depreciation->name = $name;
$depreciation->number = $data[1];
$carrying_amount = $data[2];
$carrying_amount = str_replace(",", ".", $carrying_amount);
$carrying_amount = str_replace(" ", "", $carrying_amount);
$depreciation->carrying_amount = $carrying_amount;
$sum = $data[3];
$sum = str_replace(",", ".", $sum);
$sum = str_replace(" ", "", $sum);
$depreciation->sum = $sum;
$residual_value = $data[4];
$residual_value = str_replace(",", ".", $residual_value);
$residual_value = str_replace(" ", "", $residual_value);
$depreciation->residual_value = $residual_value;
$depreciation->report_id = $id;
$depreciation->save();
}
}
}
return redirect()->back();
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']);
if ($validator->fails()) {
return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
}
if (Input::file('file')->isValid()) {
$filePath = date('Ymd_His') . '.pdf';
if (Input::file('file')->move(base_path() . '/public/uploads/Announces/Announce-' . $request->get('year'), $filePath)) {
//example of delete exist file
$announceList = Announce::all();
if (sizeof($announceList) != 0) {
$lastAnnounce = $announceList[sizeof($announceList) - 1];
$filename = base_path() . '/public/uploads/Announces/Announce-/' . $request->get('year') . '/' . $lastAnnounce->file_path;
if (File::exists($filename)) {
File::delete($filename);
}
// $oldAnnounce = Announce::findOrNew($lastAnnounce->id);
$lastAnnounce = DB::table('announces')->where('year', $request->get('year'))->first();
// dd($lastAnnounce);die;
if ($lastAnnounce != null) {
Announce::destroy($lastAnnounce->id);
}
}
$announce = new Announce();
$announce->file_path = $filePath;
$announce->year = $request->get('year');
$announce->save();
return redirect('/announces');
} else {
return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
}
}
}
示例4: excel
public function excel(Request $request)
{
try {
Log::info(Input::file('input_excel'));
Excel::load($request->file('input_excel'), function ($reader) {
$array = $reader->toArray();
Log::info($array);
$banqueId = $this->gestSession->addBanqueByExcel($array[0]);
Log::info("IdBanque1 " . $banqueId);
$i = 1;
while ($i < sizeof($array)) {
Log::info($array);
$titreIdGItem = $this->gestSession->addTitreGItemByExcel($array[$i]);
Log::info("IdTitreGItem " . $titreIdGItem);
$i++;
while ($i < sizeof($array) && $array[$i]["label_item"] != null) {
$this->gestSession->addItemByExcel($array[$i], $banqueId, $titreIdGItem);
$i++;
}
}
});
return Redirect::back();
} catch (\Exception $e) {
echo "Format Incorrect";
}
}
示例5: setUserPic
public function setUserPic($token)
{
$userId = DB::table('tokens')->where('token', '=', $token)->select('tokens.userId')->first();
$userId = $userId->userId;
$file = array('image' => Input::file('image'));
$rules = array('image' => 'required|image|max:200');
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
$error = $validator->errors()->all();
return response()->json(['errorMessage' => $error], 404);
} else {
if (Input::file('image')->isValid()) {
$destinationPath = public_path() . '/img/profile';
$extension = Input::file('image')->getClientOriginalExtension();
$fileName = 'image' . $userId . '.' . $extension;
Input::file('image')->move($destinationPath, $fileName);
$user = User::find($userId);
if ($user->picture != null) {
$picture = DB::table('users')->where('id', '=', $userId)->select('users.picture')->first();
$picture = $picture->picture;
File::delete('img/profile/' . $picture);
DB::table('users')->where('id', '=', $userId)->update(array('picture' => ''));
}
$user->picture = $fileName;
$user->save();
return response()->json(['message' => 'file uploaded']);
} else {
return response()->json(['errorMessage' => 'upload failed'], 404);
}
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'year' => 'required']);
if ($validator->fails()) {
return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
}
//example of delete exist file
$existMeetingReport = MeetingReport::where('year', '=', $request->get('year'))->where('no', '=', $request->get('no'))->first();
if ($existMeetingReport != null) {
$filename = base_path() . '/public/uploads/Meeting-reports/' . $request->get('year') . '/' . $existMeetingReport->file_path;
if (File::exists($filename)) {
File::delete($filename);
}
MeetingReport::destroy($existMeetingReport->id);
}
if (Input::file('file')->isValid()) {
$filePath = $request->get('no') . '.pdf';
if (Input::file('file')->move(base_path() . '/public/uploads/Meeting-reports/' . $request->get('year'), $filePath)) {
$meetingReport = new MeetingReport();
$meetingReport->file_path = $filePath;
$meetingReport->year = $request->get('year');
$meetingReport->no = $request->get('no');
$meetingReport->save();
return redirect('/admin/management');
} else {
return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
}
}
}
示例7: postCreate
public function postCreate()
{
$validator = Validator::make(Input::all(), ProductImage::$rules);
if ($validator->passes()) {
$images = Input::file('images');
$file_count = count($images);
$uploadcount = 0;
foreach ($images as $image) {
if ($image) {
$product_image = new ProductImage();
$product_image->product_id = Input::get('product_id');
$product_image->title = $image->getClientOriginalName();
$filename = date('Y-m-d-H:i:s') . "-" . $product_image->title;
$path = public_path('img/products/' . $filename);
$path_thumb = public_path('img/products/thumb/' . $filename);
Image::make($image->getRealPath())->resize(640, 480)->save($path);
Image::make($image->getRealPath())->resize(177, 177)->save($path_thumb);
$product_image->url = $filename;
$product_image->save();
$uploadcount++;
}
}
if ($uploadcount == $file_count) {
return Redirect::back();
} else {
return Redirect::back()->with('message', 'Ошибка загрузки фотографии');
}
}
return Redirect::to('admin/products/index')->with('message', 'Ошибка сохранения')->withErrors($validator)->withInput();
}
示例8: postCreate
public function postCreate()
{
$rules = array('name' => 'required', 'cover_image' => 'required|image');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::route('create_album_form')->withErrors($validator)->withInput();
}
// end if
$file = Input::file('cover_image');
$random_name = str_random(8);
$destinationPath = 'albums/';
$extension = $file->getClientOriginalExtension();
$filename = $random_name . "." . $extension;
$uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename);
$album = Album::create(array('name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename, 'user_id' => \Sentry::getUser()->id));
/*
$filename = Input::file('cover_image');
$random_name = str_random(8);
$destinationPath = 'albums/';
$extension = $filename->getClientOriginalExtension();
$uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename . "." . $extension);
$album = Album::create(array(
'name' => Input::get('name'),
'description' => Input::get('description'),
'cover_image' => $filename . "." . $extension,
));
*/
return Redirect::route('show_album', array('id' => $album->id));
}
示例9: store
/**
* Store a newly uploaded resource in storage.
*
* @return Response
*/
public function store(ImageRequest $request)
{
$input = $request->all();
if (Auth::user()->image != null) {
$image = Auth::user()->image;
$file = Input::file('image');
$name = time() . '-' . $file->getClientOriginalName();
$image->filePath = $name;
$file->move(public_path() . '/images/', $name);
} else {
// Store records process
$image = new Image();
$this->validate($request, ['title' => 'required', 'image' => 'required']);
$image->title = $request->title;
$image->description = $request->description;
$image->user_id = Auth::user()->id;
if ($request->hasFile('image')) {
$file = Input::file('image');
$name = time() . '-' . $file->getClientOriginalName();
$image->filePath = $name;
$file->move(public_path() . '/images/', $name);
}
}
$image->save();
$user = Auth::user();
return redirect('/' . $user->username);
}
示例10: saveData
public function saveData($request, $member_id = '')
{
// Upload
$file_upload = Input::file('avatar');
$avatar = '';
if ($file_upload) {
$filename = $file_upload->getClientOriginalName();
$extension = $file_upload->getClientOriginalExtension();
$avatar = sha1($filename . time()) . '.' . $extension;
$destinationPath = config('custom.path_upload_member');
$file_upload->move($destinationPath, $avatar);
}
if ($member_id) {
$member = self::find($member_id);
} else {
$member = new self();
}
$member->avatar = $avatar ? $avatar : $member->avatar;
$member->fullname = $request->input('fullname', '');
$member->team = $request->input('team_id', '');
$results = $member->save();
if ($results) {
return $member->id;
} else {
return $results;
}
}
示例11: import
public function import($entity)
{
$appHelper = new libs\AppHelper();
$className = $appHelper->getNameSpace() . $entity;
$model = new $className();
$table = $model->getTable();
$columns = \Schema::getColumnListing($table);
$key = $model->getKeyName();
$notNullColumnNames = array();
$notNullColumnsList = \DB::select(\DB::raw("SHOW COLUMNS FROM `" . $table . "` where `Null` = 'no'"));
if (!empty($notNullColumnsList)) {
foreach ($notNullColumnsList as $notNullColumn) {
$notNullColumnNames[] = $notNullColumn->Field;
}
}
$status = Input::get('status');
$filePath = null;
if (Input::hasFile('import_file') && Input::file('import_file')->isValid()) {
$filePath = Input::file('import_file')->getRealPath();
}
if ($filePath) {
\Excel::load($filePath, function ($reader) use($model, $columns, $key, $status, $notNullColumnNames) {
$this->importDataToDB($reader, $model, $columns, $key, $status, $notNullColumnNames);
});
}
$importMessage = $this->failed == true ? \Lang::get('panel::fields.importDataFailure') : \Lang::get('panel::fields.importDataSuccess');
return \Redirect::to('panel/' . $entity . '/all')->with('import_message', $importMessage);
}
示例12: import
public function import()
{
try {
$file = Input::file('pricelist');
//$path = Input::file('pricelist')->getRealPath();
$temp = null;
Excel::load($file, function ($reader) use($temp) {
//$reader->dump();
$reader->skip(1);
// Loop through all rows
$reader->each(function ($row) {
$carBrand = CarBrand::where('name', 'NISSAN')->first();
$carModel = CarModel::firstOrCreate(['name' => trim($row->d) . ' ' . trim($row->e), 'cartypeid' => $row->c, 'carbrandid' => $carBrand->id]);
$carSubModel = CarSubModel::firstOrCreate(['code' => trim($row->g), 'name' => trim($row->f), 'carmodelid' => $carModel->id]);
$pricelist = Pricelist::firstOrNew(['carmodelid' => $carModel->id, 'carsubmodelid' => $carSubModel->id, 'effectivefrom' => date('Y-m-d', strtotime(trim($row->a))), 'effectiveto' => date('Y-m-d', strtotime(trim($row->b))), 'sellingprice' => $row->i, 'accessoriesprice' => $row->j, 'sellingpricewithaccessories' => $row->h, 'margin' => $row->k, 'ws50' => $row->l, 'dms' => $row->m, 'wholesale' => $row->n, 'execusiveinternal' => $row->o, 'execusivecampaing' => $row->p, 'execusivetotalmargincampaing' => $row->q, 'internal' => $row->r, 'campaing' => $row->s, 'totalmargincampaing' => $row->t]);
$pricelist->effectivefrom = trim($row->a);
$pricelist->effectiveto = trim($row->b);
$pricelist->save();
});
});
} catch (Exception $e) {
return 'Message: ' . $e->getMessage();
}
return redirect()->action('Settings\\PricelistController@index');
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// register
// Log::info('register pochetok');
// Log::info($request);
// Log::info($request->get('first_name')); // ti dava samo value
// Log::info($request->only('first_name')); // ti dava cela niza so key value
$user = new User();
$user->first_name = $request->get('first_name');
$user->last_name = $request->get('last_name');
$user->email = $request->get('email');
$user->password = bcrypt($request->get('password'));
$user->skype_id = $request->get('skype_id');
$user->contact_number = $request->get('contact_number');
if (Input::hasFile('profile_picture')) {
Log::info('has file');
$file = Input::file('profile_picture');
$extension = pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
$filename = base64_encode($user->email) . "." . $extension;
$file->move('uploads/profile_pictures', $filename);
// vistinskata profilna slika
$image = Image::make('uploads/profile_pictures/' . $filename);
$image->fit(160, 160);
$image->save('uploads/profile_pictures/thumbnails/' . $filename);
// update vo folder
$user->profile_picture = $filename;
}
// proverka za email dali vekje ima (verojatno Eloquent sam kje vrati) imame staveno unique :)
$user->save();
}
示例14: postUpdate
public function postUpdate()
{
$id = Input::get('id');
$slide = Slider::find($id);
if ($slide) {
$image = Input::file('image');
$slide->link = Input::get('link');
$slide->weight = Input::get('weight');
if ($image) {
$slide->title = $image->getClientOriginalName();
$slide->title = $image->getClientOriginalName();
$filename = date('Y-m-d-H:i:s') . "-" . $slide->title;
$path = public_path('img/slider/' . $filename);
$path_thumb = public_path('img/slider/thumb/' . $filename);
list($width, $height) = getimagesize($image);
$coef_proportion = $width / $height;
$height_original = 320;
$height_thumb = 120;
$width_original = $coef_proportion * $height_original;
$width_thumb = $coef_proportion * $height_thumb;
Image::make($image->getRealPath())->resize($width_original, $height_original)->save($path);
Image::make($image->getRealPath())->resize($width_thumb, $height_thumb)->save($path_thumb);
$slide->image = $filename;
}
$slide->save();
return Redirect::back()->with('message', "Элемент изменён");
}
return Redirect::back()->with('message', 'Ошибка сохранения')->withInput();
}
示例15: store
public function store()
{
// getting all of the post data
$file = array('image' => Input::file('image'));
$input = Request::all();
$image = $input['image'];
// setting up rules
$rules = array('image' => 'required');
//mimes:jpeg,bmp,png and for max size max:10000
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($image, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
return Redirect::to('/')->withInput()->withErrors($validator);
} else {
// checking file is valid.
if (Input::file('image')->isValid()) {
$destinationPath = '/uploads/images';
// upload path
$extension = Input::file('image')->getClientOriginalExtension();
// getting image extension
$fileName = rand(11111, 99999) . '.' . $extension;
// renameing image
Input::file('image')->move($destinationPath, $fileName);
// uploading file to given path
// sending back with message
Session::flash('success', 'Upload successfully');
return Redirect::to('upload');
} else {
// sending back with error message.
Session::flash('error', 'uploaded file is not valid');
return Redirect::to('upload');
}
}
}