3
  <div id="image-preview">
    <input type='file'  data-ng-file-select  onchange="scope.setFile(this)" id="imgInp">
        {{theFile.name}}
    <img id="blah" src="{{imgeSrc}}" alt="Upload your picture" />

    </br>

    </div>

window.scope = $scope;
    $scope.name = 'Superhero';

    $scope.setFile = function (element) {
        $scope.$apply(function () {
            $scope.file = element.files[0];
            //$scope.file = (element.srcElement || element.target).files[0];
            console.log($scope.file);

        });
    };
/*for image upload*/
#image-preview {
    width: 465px;
    height: 250px;
    position: relative;
    overflow: hidden;
    background-color: #FFFFFF;
    color: #5D5E5E;
    margin-top:10px;
    border: dotted 3px #bdc3c7;
}
#imgInp {
    line-height: 200px;
    font-size: 200px;
    position: absolute;
    opacity: 0;
    z-index: 10;
  }
 #blah {
    position: absolute;
    z-index: 5;
    opacity: 0.8;
    cursor: pointer;
    background-color: #FFFFFF;
    width: 465px;
    height:250px;
    font-size: 20px;
    line-height: 50px;
    text-transform: uppercase;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    text-align: center;
  }
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<div id="image-preview">
 
    
    <input type='file'  data-ng-file-select  onchange="scope.setFile(this)" id="imgInp">
            
    
    {{theFile.name}}
        
    
    
 <img id="blah" src="{{imgeSrc}}" alt="Upload your picture" />
       

  </div>

here is what i did for angular js i have my controller in that i wrote that

now i am able to get file name but i would like to know is it possible to get full path of that image i know in php but in angularjs its some what new to me can i get any help

i would like to preview the user uploaded image with image tag with same input tag

1
  • It looks like you don't actually want the full path (which isn't exposed by the browser), you want to be able to preview the image before it's uploaded. See stackoverflow.com/questions/18754943/… Commented Mar 16, 2016 at 15:29

1 Answer 1

4
+50

No. Web browsers prevent it for security.

Sign up to request clarification or add additional context in comments.

1 Comment

It should be comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.