Foren / Cotonti / Extensions / Parsing HTML in custom module question

Trustmaster
#32947 26. Januar 2012, 18:00

This piece of code checks file extension, runs cot_file_check() to check if file contents is secure and uses cot_safename() to generate safe filename for storage:

$gd_supported = array('jpg', 'jpeg', 'png', 'gif');
$file_ext = strtolower(end(explode(".", $file['name'])));
$fcheck = cot_file_check($file['tmp_name'], $file['name'], $file_ext);
if(in_array($file_ext, $gd_supported) && $fcheck == 1)
{
	$file['name']= cot_safename($file['name'], true);
	$filename_full = $usr['id'].'-'.strtolower($file['name']);
May the Source be with you!