Am using Dropzone to upload files in Laravel 4.2, Below is my function which process the files after uploading.
public function postDropFiles()
{
$file = Input::file('file');
$destinationPath = 'uploads/'.Auth::user()->username.'/files/'.date('Y-m-d');
$extension = File::extension($file->getClientOriginalName());
$filename = time().str_random(12).'.'.$extension;
$upload_success = Input::file('file')->move($destinationPath, $filename);
if( $upload_success ) {
return Response::json('success', 200);//->with('uploaded','Succesiful uploaded');
} else {
return Response::json('error', 400);
}
}
The codes works fine , as you can see when response is 200 (success) am trying to pass variable name called "uploaded" (Commented) so that I can display the message to the user that the files successifully uploaded.
In my View I have something like this:
@if(Session::has('uploaded'))
<div class="notice-box"><strong>{{Session::get('uploaded')}}</strong></div>
@endif
My aim is to create a session variable after uploading and then use it to display message in View. I would appreciate any help. By the way am new to Laravel.