security - Is this safe? (PHP download script) -


i have quick question how safe do. have written php force download script , part serves file should pretty familiar:

header('content-description: file transfer'); header('content-type: application/force-download'); header('content-length: ' . filesize("user_files/".$temp_actual)); header('content-disposition: attachment; filename="'.$filename."\""); readfile("user_files/".$temp_actual); 

$filename filename see , $temp_actual real filename on server. there mountain of code above prevent bad things happening basically, users should able download content have uploaded. if upload .php file, don't want running on server, want delivered them via force downoad (and need able upload any file type).

it works intended, file extensions being force downloaded, want make absolutely can't run php or html files on server.

additional info

user_files in website root .htaccess "deny all" every file in user_files directory appended .file instead of original extension original extension replaced when user downloads file (maybe bit on top).

is user_files folder in website root? if so, upload php file , navigate http://mysite.com/user_files/somefile.php , run code. granted need know temporary name of file, if haven't already, should make sure web server set not allow pages served folder (or move outside document root).


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -