Level 3
Solved! Just increase the amount of "upload_max_size" in php.ini! Works fantastic!
Hey, I just would like to create a file upload. With this form I just would like to upload audio files, so I implement the form like:
{!! Form::open(['route'=>'beats.store', 'method'=>'post', 'class'=>'form-horizontal', 'files'=>true]) !!}
<div class="form-group{{ $errors->first('audio', ' has-error') }}">
<label for="audio" class="col-sm-2 control-label">@lang('beats.form.audio')</label>
<div class="col-sm-10">
{!! Form::file('audio') !!}
{!! $errors->first('audio', '<p class="text-danger">:message</p>') !!}
</div>
</div>
// ...
{!! Form::close() !!}
The request-rules-method looks like:
public function rules()
{
Validator::extend('audio', function($attribute, $value, $parameters)
{
$allowed = array('audio/mpeg', 'application/ogg', 'audio/wave', 'audio/aiff');
$mime = new MimeReader($value->getRealPath());
return in_array($mime->get_type(), $allowed);
});
return [
'name'=>'required',
'bpm'=>'required|numeric',
'artists'=>'required',
'selled'=>'required_if:buyable,on',
'contact'=>'required_if:buyable,on',
'audio'=>'required|audio'
];
}
An image-upload works - but every time I would like to upload an audio-file, it fails and says, "The audio field is required.". The mime type, which laravel detects, is: "application/octet stream" - on any audio-file.
Any ideas? :/
Please or to participate in this conversation.