我对laravel控制器执行ajax调用,但似乎无效。我该怎么办?
public function postSubmit($id) {//Gelen geornal id'si
header('Content-Type: application/json');
$uploaded = [];
$allowed = ['jpg', 'png'];
$succeeded = [];
$failed = [];
if(!empty($_FILES['dosya'])) {
// It seems not entering here.. I want to save file here.
}
当我在控制器中写这个时:
$allFiles = Input::all();
return $allFiles;
我在我的控制台中得到了这个:
Object {ajax: "true", file: Array[1]}
如何在控制器中获取文件?
这是剧本:
<script>
document.getElementById('submit-button').addEventListener('click', function(e) {
e.preventDefault();
var f = document.getElementById('file_input'),
app.uploader({
files: f,
processor: "{{ URL::route('category/post', array($category->id)) }}",
});
});
</script>
我有getFormData和ajax函数来获取FormData和XMLHttpRequest。