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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -