Angularjs picture upload echo __js

Source: Internet
Author: User
function Imgfile (file) {
    var reader = new FileReader ();
    $scope. Guid = (new Date ()). valueof ();   Creates a random number with a timestamp, using the
    reader.onload = function (ev) {
        $scope. $apply (function () {
            $scope. Thumb.push (;
    Reader.readasdataurl (file);  FileReader, turn the picture into Base64
$scope. img_upload = function (files) {for
  (var  img=0;img< Files.length img++) {
      $scope. Imgfilesdata.push (files[img]);
      Imgfile (files[img]);
<!--Photos -->
             <div ng-repeat="item in thumb">
                 <!-- Use the angular loop method to display the images stored in the thumb -->
                     <img ng-src="{{item}}" class="float-left padding-left-8" width="70px" height="70px"/>
             <div >
                 <div class="float-left" >
                     <input type="file" id="one-input" accept="image/*" multiple="multiple" file-model="images" style=";z-index: 99999 ;margin-left: -70px; Height: 70px;width: 70px;opacity: 0 " onchange="angular.element(this).scope().img_upload(this.files)"/>
                     <div class="width-70 height-70 float-left margin-left-5 line-height-70 background-e5 text-center" >
                         <i class="ion-image font-size-20 color-888"></i>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.