0

<input type=file name=img accept=".jpg"> is retrieving only image name instead of full path, how to fix it?

for example: if image URL is c:\images\img.jpg, It taking only img.jpg, instead of full path. it works fine in older version of browsers like iexplorer.. But not working in Chrome and Firefox.

mliebelt
  • 15,345
  • 7
  • 55
  • 92
  • Please provide little more info.. – AVM Dec 26 '14 at 11:25
  • Possible duplicate of http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav – user2314737 Dec 26 '14 at 11:26
  • 4
    This is a security issue. To prevent access to someones computer data, browsers mask the file path. You cannot access this anymore, only with activeX or Firefox/Chrome with elevated privileges. A simple Google search would've provided you with this answer. – Mouser Dec 26 '14 at 11:27
  • http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav#answer-15201258 – Naveen Kumar Alone Dec 26 '14 at 11:32

1 Answers1

0

Try this:

$filePath = realpath($_FILES["file"]["tmp_name"]);
trejder
  • 17,148
  • 27
  • 124
  • 216
Roshan
  • 16
  • 4