Click here to Skip to main content
14,331,020 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am using file upload (input type='file') to upload files.But i didnt get full path of the file??wat is the function we need to use for this???i have used
var fullPath = $('#fileUpload1').val();
But i got only filename.Please help me to get full path..
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

For security reasons you can't set and can't read (or to be precise, when reading you got only filename or fake path) val of <input></input> when type is file...
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try this code..

i am able to get the full path..

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="JQuery.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(function () {
            $('#btn').click(function () {
                alert($('input[type=file]').val());
                return false;

            });
        });


    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="btn" runat="server" Text="some" />
    <asp:FileUpload ID="FileUpload1" runat="server" />
    </form>
</body>
</html>
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Try this
<html>
<head>
  <title>Page Title</title>
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script type="text/javascript"> 
  $(function(){
	
			$('#fiad').change( function(event) {
													var tmppath = URL.createObjectURL(event.target.files[0]);
													$("img").fadeIn("fast").attr('src',tmppath);
				
			});
  });  
  </script>
  
</head>
<body>
    
	<input type="file" id="fiad"><br><br>
	
	<img src="" width="200" style="display:none;" />
	
</body>
</html>
</br></br>
   
Comments
Member 7990418 4-Jan-15 10:33am
   
the above solution provide blob how to i convert it to string file url
Rate this:
Please Sign up or sign in to vote.

Solution 4

hi,
Solution 2 only get the value of the input file and solution 3 generates a blob.
I need to get path of the file selected. If someone have the Solution please post it.
thanks
   
Comments
Sascha Lefèvre 29-Apr-15 13:08pm
   
You posted this as a solution but it is none. Please delete it and post a new question instead. (This question is 1.5 years old.)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100