0

I am using this for uploading image from local directry

{
type : "<span style='margin:3px;'><input type='file' id='imgPath'/>
<button id='btnimg'                       
type='button' onclick='uploadImage()' style='width:110px;' 
class='download download-primary'>Upload</button></span>"
},

But i am getting fakepath in the path location while uploading an image using the chrome browser :-

" C:/fakepath/image.png"

instead of getting the full path of the directory.

Its working fine using IE browser.
How i will resolve this problem.

Dharmesh Porwal
  • 1,406
  • 2
  • 12
  • 21
User_Alpha
  • 53
  • 2
  • 10

2 Answers2

0

Chrome shows it for security purpose.

According to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is C:\fakepath.

This requirement is already implemented in Internet Explorer 8 – the real path to the file will be shown only if the page that contains the control is added to the trusted sites collection of the browser. That made sense; essentially the browser is feeding that lame C:\fakepath\ text in.

REFERENCE

Community
  • 1
  • 1
Priyank
  • 3,778
  • 3
  • 29
  • 48
  • @Priyank-So how i will get the exact path while uploading an image.Is there any other way to do this??? – User_Alpha Jan 12 '15 at 05:57
  • @Sanjit you can't get exact path in chrome due to security.but go can get only file name using javascript/jquery – Priyank Jan 12 '15 at 06:03
  • Actually i am saving the image in db, bcz of that fakepath its not getting saved and also i am using javascript for getting the path and based on that path image is to be saved in db. I want the full path to upload the image. – User_Alpha Jan 12 '15 at 06:06
0

It is not possible to get the full path of file on client machine using browser and/or jQuery/javascript. first you have to upload file to server using form and then you can use the image.