我想使用angularjs
将图像上传到服务器var fileInputElement = $('input[name=avatar]');
var formData = new FormData();
formData.append("team_name", $('input[name=team_name]').val());
formData.append("associated_users", $('input[name=associated_users]').val()); // number 123456 is immediately converted to a string "123456"
// HTML file input, chosen by user
formData.append("avatar", fileInputElement[0].files);
$http.post('groups', formData)
.then(
function (response) {
console.log(response);
//$scope.teams.push(response.data)
},
function (response) {
console.log(response);
}
);
但在我的控制器中,当我像这样返回头像时:
return "avatar =>" . Input::file('avatar');
结果是:
data:"avatar =>"
我不知道这段代码有什么问题?