I'm using Laravel 5.1.
Uploading of filetypes jpeg, gif, png is working, but pdf, doc, docx, txt filetypes are not working.
Here is my view
{!! Form::label('department','Department', ['class'=>'col-sm-2 control-label'] ) !!}
<div class="col-sm-10">
{!! Form::select('department', $departmentList, null, ['class'=>'form-control']) !!}
<span style="color: red">{{ $errors->first('department') }}</span>
</div>
<div class="form-group">
{!! Form::label('document','Chose a file or Document', ['class'=>'col-sm-2 control-label'] ) !!}
<div class="col-sm-10">
{!! Form::file('file', null, ['class'=>'form-control']) !!}
<p class="help-block">Upload your document in pdf, doc. jpg, png, tif, gif</p>
<span style="color: red"> {{ $errors->first('file') }}</span>
</div>
</div>
{!! Form::close() !}}
my FormRequest
public function rules()
{
return [
'user_id'=>'integer',
'department'=>'required',
'file'=>'required|mimes:application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/pdf, jpeg, png, gif'
];
}
}
and my controller
public function update($id, RepositoryRequest $request)
{
$repository = Repository::findOrFail($id);
$repository->department = $request->input('department');
$file = \Input::file('file');
$filename = date('Y-m-d-H:i:s').'-'.$file->getClientOriginalName();
$path =public_path('/img/repository/').$filename ;
\Image::make($file->getRealPath())->resize(468, 249)->save($path);
$repository->file = 'img/repository/'.$filename;
$repository->save();
return redirect('/')->with('flash_message', 'You have successfully updated the repository');
This is the error:
NotReadableException in Decoder.php line 21: Unable to read image from file (/tmp/phpdNQvEG).