0

I have an html upload/browsing field as below

<html>
  <head>
    <script>
              function get_image_or_files_path()
              {  
                 var files = document.getElementById("selectedFile").files;
                 for (var i = 0; i < files.length; i++)
                    console.log(files[i].name+'>>>>>>>>>>>>>>>');
              }       
    </script>
  </head>
  <body>
     <input type="file" id="selectedFile" name="get_image_path" onfocusout="get_image_or_files_path()"/>
  </body>
</html>

So by the above javascript, i can able to get the file/image name, but how to get the url/path of the file/image

Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
  • On the client machine, or the server? – Blazemonger Oct 31 '13 at 16:58
  • Actually i am new to javascript/jquery, i want on the client/user machine when trying to upload a file, because i want to fetch that and show him a thumbnail of the image that he has selected before submitting to the server – Shiva Krishna Bavandla Oct 31 '13 at 17:00
  • You can't access the local file system. – emerson.marini Oct 31 '13 at 17:01
  • Take a look this post. [you can't do it][1] [1]: http://stackoverflow.com/a/4176605/2545964 – gon250 Oct 31 '13 at 17:02
  • becasue after submitting to the server, anyway we will have the image in database so simply we can display it, so when a user uploads an image, immediately i need to fetch the image path and show him it – Shiva Krishna Bavandla Oct 31 '13 at 17:03
  • possible duplicate of [How to get the full path of the file from a file input](http://stackoverflow.com/questions/4176377/how-to-get-the-full-path-of-the-file-from-a-file-input) – emerson.marini Oct 31 '13 at 17:03
  • possible duplicate of [Full path from file input using jQuery](http://stackoverflow.com/questions/3489133/full-path-from-file-input-using-jquery) – Blazemonger Oct 31 '13 at 17:06
  • but how like `jQuery-File-Upload` will generate a preview of the image ? https://github.com/blueimp/jQuery-File-Upload/ – Shiva Krishna Bavandla Oct 31 '13 at 17:07
  • k then is there any way to generate the preview of the image, before uploading to the server, because some sites will do so right? – Shiva Krishna Bavandla Oct 31 '13 at 17:11
  • You can do that using the file api, in browsers that support it. – Kevin B Oct 31 '13 at 17:18
  • can u please provide me an example and move in a right direction to accomplish this task ? – Shiva Krishna Bavandla Oct 31 '13 at 17:29
  • possible duplicate of [How to get full path of selected file on change of using javascript, jquery-ajax?](http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav) – Quentin Oct 31 '13 at 17:43
  • The solution then, is to use canvas : http://stackoverflow.com/questions/19115758/resizing-image-and-set-it-to-the-inputfile/19288727#19288727 – vanessen Nov 04 '13 at 15:16

0 Answers0