Getting the following error
Unable to create the "http://website.com/public/uploads/" directory
My code:
$file = Input::file('upload');
$file_name = $file->getClientOriginalName();
$file_size = round($file->getSize() / 1024);
$file_ex = $file->getClientOriginalExtension();
$file_mime = $file->getMimeType();
if (!in_array($file_ex, array('jpg', 'gif', 'png'))) return Redirect::to('/')->withErrors('Invalid image extension we just allow JPG, GIF, PNG');
$newname = $file_name;
$file->move(URL::to('/').'/uploads/', $newname);
The uploads folder exists.
It can also be done like this:
For a unique file name, you can add
time()
function like this:You are trying to move a file to a URL, you have to move to a folder: