protect users' file being accessed so only owner can access?

前端 未结 3 1564
离开以前
离开以前 2021-01-15 16:57

I am writing a web application in php where users can upload their own files or images, but how can I protect these files from being accessed by others other than the owner

3条回答
  •  梦谈多话
    2021-01-15 17:39

    use unique and special file names, and only present them to the disired user. you can alsso set a session in PHP and check if the session is correcvt to include a file. and use httacces tio redirect to the PHP.

    the specialkey is set in the PHP page making the display page, and is unique for evey file and is gained from DB. it's the fastest way I could ciomme up with.

    you might olso want to store the files in a dir that is only accesable from PHP

    edit instead of include you could use Jani Hartikainen method

提交回复
热议问题