Topic Fileupload
I was wondering if it is possible to automaticallly change the filename , to prevent uploading files with special german characters like "ä,ö,ü,ß or even empty space"
Example:"Meier,Ölke pedo.jpg-1.jpg" should become: "meieroelkepedojpg-1.jpg". I noticed that in xataface filenames are changed automatically to prevent overwriting (filename+Int++). Can i safely extend this funktion? Where can i find it?
for the image_filename field its quite easy (excuse my sloppy coding style)
- Code: Select all
function beforeInsert(&$record){
$vokale = array(" ", ",", "ö", "ä", "ü", "Ö", "Ä", "Ü", "ß", "/");
$before = $record->val('image_filename');
$uniq = rand(1,100000);
//$h = haystack, $n = needle
function strstrb($h,$n){
return array_shift(explode($n,$h,2));
}
$after1 = strstrb($before,'.');
$after = str_replace($vokale, "", $after1);
$record->setValue('extra', $after."".$uniq.".flv");
//$record->setValue('image_filename', str_replace($vokale, "", $before));
}
but how about the file itself?
cheers
Martin