开发者

Storing Files on the server in a non-public-accessible directory

I can't seem to find information on how to do this. How can I use PHP to let a user upload a file on my website and then save that file on my 开发者_如何学Pythonserver somewhere, but save it somewhere where noone can browse to its location? This will mainly be for PDF files, but they can also upload TXT or DOC/DOCX files, if that matters.

Any help is appreciated

Thank you


it depends on what your web server setup is like.

If you are on a shared web host, some companies only have web accessible folders for each shared host client, others provide non-publicly accessible folders. To check for this login through ftp and if you see either a www or public-html then anything that is not in that folder should not be accessible.

If you have a non-publicly accessible folder, good!

Learn to love move_uploaded_file()manual.

Just set the destination folder of the move_uploaded_file to a folder that isn't inside the web root and you're good.

If you do not have a non-publicly accessible folder, you need some .htaccess magic. (Here is a starting point.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜