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

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -