温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

angularJS file-up-load上传图片

发布时间:2020-06-28 11:50:50 来源:网络 阅读:540 作者:紫枫5966 栏目:开发技术

                        <div class="form-group">
                            <label class="col-xs-2 control-label col-xs-offset-1">系统图片</label>
                            <div class="col-xs-7">
                                   <div class="input-group" ng-show="YES">
                                
                                    <input class="file-name form-control" type="text" readonly="readonly" id="fileItem" value="`fileItem`.`name`" ng-model="fileItem.name"/>
                                    <div class="input-group-btn">
                                        <input type="file"  accept="p_w_picpath/*"  file-model="myFile" name="certificate" class='input-file files fff' id="f" onchange="txt.value=this.value"  size="1" hidefocus nv-file-select uploader="uploader"/>
                                        <input type="button" onmousemove="f.style.pixelLeft=event.x-60;f.style.pixelTop=this.offsetTop;"  value="选择图片" size="30" onclick="f.click()" class=" btn-info btn liulan">
                                    </div>
                                  </div>
                                <div class="input-group" ng-show="NO">
                                     <div class="input-group-btn">
                                          <input class="form-control" readonly type="text" name="branchPn_add" name="sysImagePc_add" value="`sysImagePc_add`" ng-model="sysImagePc_add" >
                                        <input type="button"  value="重新选择" ng-click="chooseAgain()" size="30" class=" btn-info btn liulan">
                                     </div>
                                  </div>
                                  
                                  <div class="input-group imgSrc" ng-show="YESs">
                                         <img ng-src="`p_w_picpathSrc`" id="iSrc" />
                                  </div>
                                  <br />
                                <a class="btn btn-info" ng-click='UploadFile()'>上传</a>
                                <a class="btn btn-default" ng-click="EditloadFile()">取消</a>
                            </div>
                            
           
                               
                          </div>


           //新增系统-开始出现弹窗
           $scope.addSystem = function(){
               $scope.YESs = t2;
               $scope.YES = t1;
               $scope.NO = t2;
               $scope.p_w_picpathSrc = "";
               $('#fileItem').val("");
//               $scope.createUser_add = $scope.LoginList.employeeName
           }
           //新增系统-重新选择
           $scope.chooseAgain = function(){
               $scope.YES = t1;
               $scope.YESs = t2;
               $scope.NO = t2;
               $scope.fileItem = null;
               $scope.p_w_picpathSrc = false;
           }
            
           //新增系统-上传图片预览
           $scope.getFile = function () {
               fileReader.readAsDataUrl($scope.file, $scope)
                 .then(function(result) {
                     $scope.sysImagePc_edit = result;
                     $scope.YESs = t1;
                     $scope.sysImagePc_edit = result;
                     $scope.p_w_picpathSrc = result;
                     $scope.fileItem = $scope.file;
                 });
           };
           
           //新增系统-点击上传
           $scope.uploadStatus = false;
           var uploader = $scope.uploader = new FileUploader({
               url: '/FileServlet',
               queueLimit: 1,
               removeAfterUpload: true
           });
           uploader.onAfterAddingFile = function(fileItem) {
               $scope.fileItem = fileItem._file;
           };
           uploader.onSuccessItem = function(fileItem, response, status, headers) {
               $scope.uploadStatus = true;
               $scope.sysImagePc_add = response;
               $scope.sysImagePc_edit = response;
               $scope.YESs = t2;
               $scope.YES = t2;
               $scope.NO = t1;
           };
           $scope.UploadFile = function(){
               uploader.uploadAll();
           };
           
           //新增产品-选择图片--取消
           $scope.EditloadFile = function(){
               $scope.YES = t1;
               $scope.YESs = t2;
               $scope.NO = t2;
               $('#fileItem').val("");
               $scope.fileItem = $scope.sysImagePc_edit;
           };

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI