我使用了Chrome的高级休息控制台,并且我向服务器发送了一个将图像保存到数据库的休息请求。
标题数据和请求正文下面的:
标题
内容类型:image / jpg;字符集= UTF-8
体:
DEVICE_ID = 1442045686166&安培; id_utente = 1&安培; id_attivita = -1&安培; id_prodotto = 115安培; FILE = / 9J / 4AAQSkZJRgABAQAAAQABAAD /...
服务器,而不是我的,这一切都回来了,但这是结果 image returned
其他图片是从Android应用程序上传的,该应用程序将请求发送到同一台服务器!
服务器是部署在jboss应用服务器上的java Web应用程序。
这是retrive图像的html部分:
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<label for="exampleInputEmail1">Immagine</label>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="thumbnail">
<i ng-hide="imageSrc">Nessuna immagine selezionata</i>
<img ng-hide="!imageSrc" ng-src="{{imageSrc}}" on-error-src="images/noimg.png" spinner-on-load/>
<div class="caption">
<div class="form-group">
<input type="file" id="imageInputFile" name="imageInputFile" ng-model="imageInputFile" ng-change="uploadFile(this)" ng-file-select="onFileSelect($files)" base-sixty-four-input maxsize="500" accept="image/*">
<p class="help-block">Scegli un'immagine in locale.</p>
</div>
</div>
</div>
</div>
</div>
</div>
这是angularjs代码:
$scope.uploadImage = function (id_prodotto) {
trace("uploadImage, inizio");
var img64 = $scope.imageSrc.replace(/^data:image\/(png|jpeg);base64,/, "");
$scope.bodyRawImg =
'device_id=' + $scope.key +
'&id_utente=' + $scope.BeanUtente[0].id_utente +
'&id_attivita=' + $scope.BeanUtente[0].id_attivita +
'&id_prodotto=' + id_prodotto +
'&file=' + img64;
trace("uploadImage, $scope.bodyRawImg " + $scope.bodyRawImg);
$http({
method: 'POST',
url: ($location.absUrl().split("/easyMenu/"))[0] + '/app/file/uploadFoto',
async: false,
processData: false,
headers: {
'Content-Type': 'image/jpg'
},
data: $scope.bodyRawImg,
})
.success(function (data, status, headers, config) { // success
trace("uploadImage, success");
$scope.result = (data || []);
trace("uploadImage response: " + JSON.stringify($scope.result));
})
.error(function (data, status, headers, config) { // error
trace("uploadImage, error");
});
$scope.cambioImmagine = false;