php - Configuring Apache for Large Uploads -
i developing file uploading service company. our users sending large .zip files filled large illustrator files. files won't larger 1.5gb, need plan on handling files 4gb.
obviously, causes lot of concerns around how configure apache allow such large file transfers without overloading server or opening security holes.
concern 1: memory limits
one feature of system users should able download files after have uploaded them. i've avoided using standard download (just link file) because of security issues - can't let other user's download each others files. solution keep uploaded files in protected directory outside of www-root, , load them in via php script. php script looks little this:
$fo = fopen($uploaddir.$file_name, "r"); while(!feof($fo)) { $strang = fread($fo, 102400); echo $strang; ob_flush(); } fclose($fo);
i've put fread loop , locked loading small chunks of file @ time. did because server has 4gb of ram, , needs able handle multiple people downloading concurrently (probably max of 20 ppl). first question how large of chunk should read @ time. right downloading 1.5gb file painfully slow because of chunk size.
concern 2: max execution time
another issue of uploading/downloading such large files max execution time. while pretty speed on internal network, should prepared users slow connections. i'm setting lower-end upload rate @ 1mbps, comes 35 minutes uploading.. let's generous , can download @ twice speed, 15ish minutes download.
is security risk set max_excution_time 30 minutes? going kill on server? don't have reason think it's bad idea, gut screaming stupid allow script run long. there better way i'm trying do?
i've seen couple other similar questions, , of them suggested using java or silverlight. to, if there sensible way, avoid java. using swfupload , accompanying jquery plugin.
concern 1: memory limits
readfile
streams, converted http response on fly , won't loaded memory completed.
for uploads however, script must have enough memory because while uploading , using php whole file goes memory if remember right.
concern 2: max execution time
if you're concerned security, handle authentication , access rights via httpd server. script won't executed when request not valid.
Comments
Post a Comment