Upload non-alphanumeric filename using Tinybrowser

Try uploading a non-alphanumeric or an image with UTF-8 filename via tinybrowser and you will notice that the image fail to display on IE. That is because IE dont recgonise the filename. The clean_filename function in thinybrowser doesn't seem to work well in filtering the filename, here is what we've done to overcome the issue:

Look for the file "fns_tinybrowser.php", search for the function "clean_filename". Do take note that the filename passed-in to this function ends will a "underscore" (abc.jpg_). What we do first, is to extract the file extension(.jpg_), then validate if the filename is UTF, is yes, simply replace it an alphanumeric name, if not, strip the filename to alphanumeric with "preg_replace("/[^a-zA-Z0-9-]/", "", $filename)". Once you got the alphanumeric filename, join the string with the extension and you are all good!

//function to clean a filename string so it is a valid filename

function clean_filename($filename)
 $utf_file_ext = find_file_ext($filename);
  $filename = "file".datetime_to_unique_number().".".$utf_file_ext;
  $filename = preg_replace("/[^a-zA-Z0-9-]/", "", $filename).".".$utf_file_ext;

Cresenture Pte Ltd

Follow Us

Help & Support

User Login