Skip to content

Instantly share code, notes, and snippets.

@jackabox
Created December 7, 2013 16:02
Show Gist options
  • Save jackabox/7844373 to your computer and use it in GitHub Desktop.
Save jackabox/7844373 to your computer and use it in GitHub Desktop.
File upload in L4
$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