Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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...
 
Share this answer
 
Try this code..

i am able to get the full path..

XML
<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>
 
Share this answer
 
Try this
JavaScript
<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>
 
Share this answer
 
Comments
Member 7990418 4-Jan-15 10:33am    
the above solution provide blob how to i convert it to string file url
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
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900