0

Is it possible to get the image path from where it is selected in jquery before upload to a particular folder.

5
  • "Is it possible to get the image path from where it is selected in jquery before upload to a particular folder." No. It is possible to retrieve image name Commented Sep 10, 2015 at 4:49
  • Any other way to display an image before upload to a folder,which means display the image on browsing Commented Sep 10, 2015 at 4:57
  • Yes, image could be displayed when selected by user, before upload. Can include html , js at Question ? Commented Sep 10, 2015 at 4:59
  • Help me to display the image Commented Sep 10, 2015 at 5:06
  • This link might help you Commented Sep 10, 2015 at 5:11

1 Answer 1

1

Try utilizing change event , URL.createObjectURL with this.files[0] as argument

$("input[type=file]").on("change", function() {
  $("[for=file]").html(this.files[0].name);
  $("#preview").attr("src", URL.createObjectURL(this.files[0]));
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<input id="file" type="file" accepts="image/*" /><br />
<label for="file"></label><br />
<img id="preview" />

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

2 Comments

First of all thanks for your support.Here I need to display multiple images also.I have the below code for displaying images in dynamically generated div.div = $('<div class="photoclass" />'); img = $('<img />', { 'src': URL.createObjectURL(this.files[0]) }).prependTo(div); div.appendTo('.photo_inner'); Any idea please help?
@Neethu "need to display multiple images also." Not appear at original Question ? See stackoverflow.com/help/how-to-ask . Tried using a loop for each this.files ? See also stackoverflow.com/questions/28856729/…

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.