php - Uploading a file to a different directory on server -
i using php allow users upload photos on web app.
i using php function:
move_uploaded_file();
and define upload path:
define('uploadpath', 'images/');
to place photo in images/ directory
now want give users ability same thing, sub domain of website.
do do:
define('uploadpath', 'http:/mobile.website.com/images/');
if so, how prevent others uploading malicious files server, server?
first of second argument of move_uploaded_file()
should directory, not url,
i mean correct :
define('uploadpath', 'mobile/images/'); move_uploaded_file($tmp,uploadpath.$name);
but not :
define('uploadpath', 'http:/mobile.website.com/images/'); move_uploaded_file($tmp,uploadpath.$name);
second of all, preventing others uploading malicious files server, better check extension of file.
Comments
Post a Comment