1
anglejsで画像をアップロードしようとしています。anglejsで画像をアップロードするには
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(内部サーバーエラー)が表示されています。
私が間違っていることを教えてください。
ありがとうございます。