Created
December 7, 2013 16:02
-
-
Save jackabox/7844373 to your computer and use it in GitHub Desktop.
File upload in L4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rules = array( | |
'image' => 'image|mimes:jpg,jpeg,png|max:3000', | |
); | |
$validation = Validator::make($input, $rules); | |
if ($validation->fails()) { | |
return Response::make($validation->errors->first(), 400); | |
} | |
if (Input::hasFile('image')) { | |
$file = Input::file('image'); | |
$destinationPath = public_path() . '/uploads/blog/'.str_random(8); | |
$filename = $file->getClientOriginalName(); | |
$uploadSuccess = Input::file('image')->move($destinationPath, $filename); | |
} else { | |
$destinationPath = ''; | |
$filename = ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment