angularjs图片上传
2016-12-01 17:57
363 查看
引入
ng-file-upload-shim(.min).js //h5不支持的浏览器
ng-file-upload(.min).js
页面使用:
<img data-ngf-src="examplePicFile1 || defaultPicFile"/>
<button data-ngf-select="selectFile($file,0)" data-ngf-pattern="'.png,.jpg,.gif'" data-ngf-multiple="false">按钮文字</button>
<img data-ngf-src="examplePicFile2 || defaultPicFile"/>
<button data-ngf-select="selectFile($file,1)" data-ngf-pattern="'.png,.jpg,.gif'" data-ngf-multiple="false">按钮文字</button>
js:
$scope.defaultPicFile = "图片url"//提示图片
$scope.examplePicFile1 = "";
$scope.examplePicFile2 = "";
//data-ngf-multiple 控制选择单/多张图片true $file 是 数组
$scope.selectFile = function(file,id){
if(id==0){
$scope.examplePicFile1 = file;
//选择后及上传可执行上传方法
//upload();
}else if(id == 1){
$scope.examplePicFile2 = file;
}
}
ng-file-upload-shim(.min).js //h5不支持的浏览器
ng-file-upload(.min).js
页面使用:
<img data-ngf-src="examplePicFile1 || defaultPicFile"/>
<button data-ngf-select="selectFile($file,0)" data-ngf-pattern="'.png,.jpg,.gif'" data-ngf-multiple="false">按钮文字</button>
<img data-ngf-src="examplePicFile2 || defaultPicFile"/>
<button data-ngf-select="selectFile($file,1)" data-ngf-pattern="'.png,.jpg,.gif'" data-ngf-multiple="false">按钮文字</button>
js:
$scope.defaultPicFile = "图片url"//提示图片
$scope.examplePicFile1 = "";
$scope.examplePicFile2 = "";
//data-ngf-multiple 控制选择单/多张图片true $file 是 数组
$scope.selectFile = function(file,id){
if(id==0){
$scope.examplePicFile1 = file;
//选择后及上传可执行上传方法
//upload();
}else if(id == 1){
$scope.examplePicFile2 = file;
}
}
相关文章推荐
- angularjs客户端实现压缩图片文件并上传实例
- angularjs图片上传后不刷新的解决办法
- 通过AngularJS实现图片上传及缩略图展示示例
- Angularjs上传图片预览--关键代码
- angularjs 实现图片上传实时预览
- angularjs上传图片预览
- angularjs 图片上传 回显
- angularjs实现多张图片上传并预览功能
- AngularJS用原生的fileinput上传图片
- AngularJS图片上传功能实践
- AngularJS图片上传功能的实现
- angularJs中上传图片/文件功能:ng-file-upload
- angularJs中上传图片/文件功能:ng-file-upload
- angularjs上传多张图片并预览
- angularjs上传图片插件使用
- angularjs客户端实现压缩图片文件并上传实例
- angularjs上传图片并转换成base64保存到数据库
- SpringMVC实现angularjs图片上传
- angularjs上传图片控件
- angularjs手机webapp 利用input拍照,图库选择上传图片