Is it possible to get the image path from where it is selected in jquery before upload to a particular folder.
Asked
Active
Viewed 8,384 times
0
-
_"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` – guest271314 Sep 10 '15 at 04:49
-
Any other way to display an image before upload to a folder,which means display the image on browsing – Neethu Sep 10 '15 at 04:57
-
Yes, image could be displayed when selected by user, before upload. Can include `html` , `js` at Question ? – guest271314 Sep 10 '15 at 04:59
-
Help me to display the image – Neethu Sep 10 '15 at 05:06
-
**[This link](http://www.aspsnippets.com/Articles/Show-Display-image-preview-before-upload-using-jQuery.aspx)** might help you – Guruprasad J Rao Sep 10 '15 at 05:11
1 Answers
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" />

guest271314
- 1
- 15
- 104
- 177
-
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 = $(''); img = $('
', { 'src': URL.createObjectURL(this.files[0]) }).prependTo(div); div.appendTo('.photo_inner'); Any idea please help? – Neethu Sep 10 '15 at 06:28
-
@Neethu _"need to display multiple images also."_ Not appear at original Question ? See http://stackoverflow.com/help/how-to-ask . Tried using a loop for each `this.files` ? See also http://stackoverflow.com/questions/28856729/upload-multiple-image-using-ajax-php-and-jquery/ – guest271314 Sep 10 '15 at 06:35