I am creating an app which needs to upload files, specifically videos and I am using laravel to do server-side php.
I have a form on my view
{{ Form::open(array('route' => 'testuploads.store', 'files' => true, 'enctype' => 'multipart/form-data')) }}
<ul>
<li>
{{ Form::label('title', 'Title:') }}
{{ Form::text('title') }}
</li>
<li>
{{ Form::label('body', 'Body:') }}
{{ Form::textarea('body') }}
</li>
<li>
{{ Form::token() }}
{{ Form::label('file', 'File:') }}
{{ Form::file('file') }}
</li>
<li>
{{ Form::submit('Submit', array('class' => 'btn btn-info')) }}
</li>
</ul>
{{ Form::close() }}
A controller
public function store()
{
$input = Input::all();
$file = Input::file('file');
$pubpath = public_path();
$destinationPath = $pubpath.'/uploads/'.str_random(8);
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
// $path = $file->getRealPath();
$size = $file->getSize();
$mime = $file->getMimeType();
$uploadSuccess = Input::file('file')->move($destinationPath, $filename);
$validation = Validator::make($input, Testupload::$rules);
if ($validation->passes())
{
$this->testupload->create($input);
return Redirect::route('testuploads.index');
}
return Redirect::route('testuploads.create')
->withInput()
->withErrors($validation)
->with('message', 'There were validation errors.');
}
The error I get is:
Symfony \ Component \ HttpFoundation \ File \ Exception \ FileException
Unable to create the "/www/test/public/uploads/xTzlVlxb" directory
I have tried to change the permissions to the upload directory too, but that didn't worked. Any help appreciated, thanks.
/www/test/public/uploads/writable?