如何上传fatFramework中的文件。我使用angularjs在fatfree框架中发送post请求。我想使用文件扩展名.jpg和大小2mb,并且只限制4个文件。请指导我。如何在无脂框架中上传文件?
这里是我的html代码 -
<div class="col-md-9" style="margin-bottom: 40px" ng-controller="AppController" nv-file-drop="" uploader="uploader" filters="queueLimit, customFilter">
<h3> upload</h3>
<div ng-show="uploader.isHTML5">
<input type="file" nv-file-select="" uploader="uploader" multiple /><br/>
<table class="table">
<tbody>
<tr ng-repeat="item in uploader.queue">
<td><strong>{{ item.file.name }}</strong></td>
<td ng-show="uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
<td ng-show="uploader.isHTML5">
<div class="progress" style="margin-bottom: 0;">
<div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
</div>
</td>
<td class="text-center">
<span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span>
<span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span>
<span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span>
</td>
<td nowrap>
<button type="button" class="btn btn-success btn-xs" ng-click="item.upload()" ng-disabled="item.isReady || item.isUploading || item.isSuccess">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
<button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" ng-disabled="!item.isUploading">
<span class="glyphicon glyphicon-ban-circle"></span> Cancel
</button>
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
这里是我的角度控制器
'use strict';
角
.module('app', ['angularFileUpload'])
.controller('AppController', ['$scope', 'FileUploader', function($scope, FileUploader) {
var uploader = $scope.uploader = new FileUploader({
url: 'uploadfile'
});
// FILTERS
uploader.filters.push({
name: 'customFilter',
fn: function(item /*{File|FileLikeObject}*/, options) {
return this.queue.length < 10;
}
});
console.info('uploader', uploader);
}]);
这里是我的无脂代码
$f3->route('GET|POST|PUT /uploadfile',
function($f3) use($db){
//print_r($f3['BODY']);die;
$data = $f3['BODY'];
print_r($data);
$file_name = $data['filename'];
$file = "/ui/uploads";
$file .= $id . "/";
$file .= $file_name;
$f3->set('SESSION.id', $file);
echo var_dump($file);
}
);
具体什么问题? – Tristan
无法接收图像参数。 –