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

≯℡__Kan透↙ 提交于 2019-12-01 20:57:43

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

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

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