How do I get the url of an image with an asp.net element?

1

As I can get the value of the entire url of my selected image, my current code is as follows:

Javascript code

   var image= document.getElementById('<%=fileImage.ClientID%>').value;

.aspx code

<asp:FileUpload ID="fileImage" class="fileImagen" runat="server"></asp:FileUpload>

Currently I can get only the name of the file with jquery.

Jquery Code:

var imagen = $(".fileImagen").val();

But I need to know the entire location of the file.

    
asked by David 31.03.2017 в 22:21
source

3 answers

1

For security reasons it is not possible to access via javascript the "physical" path (full path) that contains the INPUT of the file type.

That's why you can only get it with val () the name of the file

NOTE: At the time a couple of years ago in IE it could be, serious! and there was a method in FF that you could get it. But it is not a standard and you can not take it all browsers

    
answered by 01.04.2017 / 04:33
source
0

You can use the prop method by passing as an attribute the src of your image, so that:

var imagen = $(".fileImagen").prop('src');

It is valid with jQuery 1.6 or higher

    
answered by 31.03.2017 в 23:48
0
var src = document.querySelector('#fileImage').getAttribute('src');

that code js should walk

    
answered by 01.04.2017 в 03:59