1
我想使用https://github.com/danialfarid/ng-file-upload/進行文件上傳。我正在嘗試使用$_FILES
全局陣列來捕獲上傳的文件。雖然文件的內容被髮送到服務器,但似乎PHP無法捕獲上傳的文件元數據(文件名等)。所以$ _FILES是空的。順便說一句,這是奇怪的是,我應該設置兩個文件和數據屬性file
$scope.upload = function (files) {
if (files != null && files[0]) {
var file = files[0];
console.log(file);
file.upload = Upload.http({
url: 'rest/file/',
data:file,
fileName:'test',
file: file
});
file.upload.then(function (response) {
file.result = response.data;
}, function (response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
});
file.upload.progress(function (evt) {
file.progress = Math.min(100, parseInt(100.0 * evt.loaded/evt.total));
});
}
}
HTML標記:
<p>
<label for="background">Background</label>
<input ngf-select ngf-change="upload($files)" accept="image/*"
ng-model="form.background"
name="background" type="file"/>
<img ng-show="form.background[0] != null" ngf-thumbnail="form.background[0]" class="thumb"/>
<span class="meter" ng-show="form.background[0].progress >= 0">
<span style="width:{{form.background[0].progress}}%"
ng-bind="form.background[0].progress + '%'"
class="ng-binding">
</span>
</span>
</p>
hi @phpst,你找到了解決辦法嗎? –
我不記得了。我轉移到https://blueimp.github.io/jQuery-File-Upload/ – PHPst