security - How to unlink file securly in php? -


i need delete image files in /var/www/mysite/postimage folder unlink() function in php. i'm absolutely worried if hacked site , using .. or . in path , try delete in upper level folder. i'm using jquery send path , because it's client side programming it's dangerous. know , can bypass dots when uploading files if changes path in client side adding dots it? question how prevent doing that?

  1. make sure apache user has proper rights(writing in website directory)
  2. cut .. path, sanitize , validate path if it's correct.
  3. you can use realpath() function.

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -