Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

flash uploader file name issue
https://www.tinywebgallery.com/forum/viewtopic.php?f=12&t=1335
Page 1 of 1

Author:  archieboy [ 31. Dec 2007, 00:23 ]
Post subject:  flash uploader file name issue

twg flash uploader is allowing illegal linux file names to be uploaded. File names with quotes (') to be when uploaded cause problems with php and other scripts.

Is there any way the frontend can validate the file names before upload and reject with an error message to the webuser?

Author:  TinyWebGallery [ 3. Jan 2008, 18:46 ]
Post subject: 

if ' are not handled properly (escaped) in php they can cause trouble in script s that are not programmed well.

Flash does not support regular expressions. But I do add a string of not allowed characters in the next version of TFU.

Until then you should handle this problem on the php side before saving the file by e.g. replacing the ' with something else.

/Michael

Author:  archieboy [ 4. Jan 2008, 17:00 ]
Post subject: 

I found this nice little php function to cleanup filenames i added it to the tfu_upload.php

Code:

After
if ($store) {

insert
$file['name'] = removeSpacesFromFileNames($file['name']);

at the bottom befor the ?> insert

function removeSpacesFromFileNames($imageName){
$patternCounter=0;
$patterns[$patternCounter] = '/[\x20-\x2d]/u'; // remove range of shifted characters on keyboard - !"#$%&'()*+,-
$patternCounter++;

$patterns[$patternCounter] = '/[\x5b-\x60]/u'; // remove range including brackets - []\^_`
$patternCounter++;

$patterns[$patternCounter] = '/[\x7b-\xff]/u'; // remove all characters above the letter z.  This will eliminate some non-English language letters
$patternCounter++;

$replacement ="_";

return preg_replace($patterns, $replacement, $imageName);
}

Author:  TinyWebGallery [ 4. Jan 2008, 17:09 ]
Post subject: 

If this works for you that's fine.

But I cannot remove this characters by default. Spaces and special characters are needed like öäü [] ... are all valid characters.

TFU does even support chinese chars for upload. Therefore if you need a restriction you should simply keep your solution.

/Michael

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/