Getting the Full Path Of A File Upload Field In A Form in PHP

帅比萌擦擦* 提交于 2019-12-31 01:53:25

问题


I am using a file upload in PHP. I want to get the Full PATH of the File Selected. Is there any way i can get the full path in PHP??

For Eg: i uploaded a image from : "c:\upload\check.jpeg"
I want the full path.. as "c:\upload\check.jpeg".

i tried pathinfo, $_FILES. But no help.

Thanks in advance.


回答1:


You probably can't. Many browsers these days don't send that information, as it can give attackers information about the user's system.




回答2:


On the client side fileinput.value will give just the filename in Firefox and the full path in IE8. No browser will send the full path to the server as that would be a security issue.

However with IE (I've done this with IE8*) you can probably cheat a bit with JavaScript and put the path into a different text field to be sent with the form. Of course that would only work for IE. I would argue IE is broken since it allows you to do such nasty things.

*I wasn't sending the path to the server. I was creating a "stylish" file upload control for which I cheated by putting the selected filename in a separate text field and hid the actual file input. IE and FF differed in how the filename was displayed



来源:https://stackoverflow.com/questions/5519994/getting-the-full-path-of-a-file-upload-field-in-a-form-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!