I'm trying to upload an image from an ajax call to my server (on laravel).
This is my server code:
if (Input::hasFile('flyer')){
Log::info('WORK!');
$file = Input::file('flyer');
$file->move('uploads', $file->getClientOriginalName());
}
As you can see, I've set a log istruction to understand if my file was uploaded or not...but my log file say it's not...
My form code:
{{ Form::open(array('url' => 'new_event', 'id' => 'newEvent', 'files' => true)) }}
//some fields...
{{ Form::file('flyer', array('class' => 'form-control', 'id'=>'inputImage')) }}
// some other fields
{{ Form::close() }}
and here is my ajax call:
$('#newEvent').submit(function() {
$.ajax({
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(response) {
$('#content').html(response);
}
});
return false;
});
Finally here my post-data (from google dev console) when i post my form:
_token:bqyiuQwtYEEs0tvhBcndi4ylsVPPi2FpYhGPLxKQ
title:sdfgsdf
description:sdfgsdf
activated_at:23/04/2015
expire_on:24/04/2015
contact:a name
phone:+387646
email:some@one.com
push:1
As you can see there is no trace of my image file (flyer)...why?
Aucun commentaire:
Enregistrer un commentaire