【发布时间】:2016-07-24 04:58:54
【问题描述】:
我正在尝试使用 angularjs 上传图片。
HTML:
<input type="file" id="picture" name="picture"/>
<button class="btn btn-primary" ng-click="AddNew()" type="submit">Save</button>
Controller.js
$scope.AddNew=function(){
console.log(picture.files.item(0));
$scope.myobject.picture=picture[0];
$http({
url: 'http://localhost/mypro/resource',
method: "POST",
data: {'resource' : $scope.myobject },
headers: {'Content-Type': undefined },
transformRequest: angular.identity
})
.then(function(response) {
// success
},
function(response) { // optional
// failed
});
};
Laravel 5.2:
routes.php
Route::resource('resource','ResourceController');
控制器:
public function store(Request $request){
Log::info('request: '.print_r(Input::all(),true));
Log::info('request: '.print_r($request,true));
return array('success' => true);
}
这里只是得到空数组。 在控制台中我得到 500(内部服务器错误)。
请指导我做错了什么。
谢谢。
【问题讨论】:
标签: php angularjs laravel-5.2