I get "CLI stopped working" error when i press the upload button.I used the sample code from one of the website to upload file into the database column. I use Laravel 5.2.39. command used: php artisan serve
Code:(Only test version)
Form.blade.php
<form method="post" enctype="multipart/form-data" action="/upload_file">
<input type="file" name="file" />
<input type="submit" name="submit" value="upload" />
</form>
Routes.php(Not an ideal place to code this but it is only for file upload test purpose) Route::get('/upload_form', function() { $data['files'] = Attachment::get(); return View::make('form', $data); });
Route::post('/upload_file', function()
{
$rules = array(
'file' => 'required|mimes:doc,docx,pdf',
);
$validator = Validator::make(Input::all(), $rules);
if(Input::hasFile('file'))
{
$f = Input::file('file');
$att = new Attachment;
$att->name = $f->getClientOriginalName();
$att->file = base64_encode(file_get_contents($f->getRealPath()));
$att->mime = $f->getMimeType();
$att->size = $f->getSize();
$att->save();
return Redirect::to('/upload_form');
}
});
Has anyone encountered this issue? Need help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire