View Full Version : Characters forbidden in filenames function?

March 9th, 2008, 06:29 PM
What can be done to replace characters such as $/\\:*?"'<>|` &-

to spaces when the file gets uploaded? A file called Bean_Millennium_Park_Chicago_Illinois uploaded would turn to "Bean Millennium Park Chicago Illinois" and would work well for keywords also..

Perhaps adding an admin function called:

Characters forbidden in filenames: and a default set of characters can be entered here?

Chuck S
March 9th, 2008, 06:36 PM
actually spaces are converted to _ so the file links work in all browsers as some browsers have problems with spaces in filenames and alot of irregular characters are prevented and replaced

March 9th, 2008, 10:15 PM
How about the display file name, not the actual link name then?

So that the display name of Bean_Millennium_Park_Chicago_Illinois will not have the underscore and the keyword will not be a complete term of Bean_Millennium_Park_Chicago_Illinois?

perhaps this is a keyword issue instead - how about the keyword script to remove the characters for better keywording instead of a long term based on the filename alone. Bean Millennium Park Chicago Illinois searches way better than Bean_Millennium_Park_Chicago_Illinois

Chuck S
March 9th, 2008, 10:31 PM
well users can enter keywords for a photo when they upload. Your free to modify your code to suit your needs.

March 10th, 2008, 06:19 AM
which file containts the keyword function?

Chuck S
March 10th, 2008, 07:48 AM
What do you mean by keyword function there is n keyword function

You enter keywords on upload in uploadphoto.

March 10th, 2008, 01:21 PM
Sorry, I should have been clearer. Which file takes the filename and converts it to a keyword if no keywords are entered?

Chuck S
March 10th, 2008, 01:41 PM

March 11th, 2008, 09:00 AM
by the looks of it, the keywords in the db are actually NOT the title of the images, rather, it is using the title of the image IF there are no keywords.. correct?


if ( empty($keywords) )

Add above:
// preg_replace below strip out any punctuation and spaces from title, replacing such characters with spaces for better keywords
$title = preg_replace("/[^a-zA-Z0-9s.]/", " ", $title);

this will replace the 'forbidden' characters in the title and keywords (if title used) to spaces for better keyword searching.

Chuck S
March 11th, 2008, 09:23 AM
yes we use the title there are no keywords and we dont check anything to do with a title as anyone can type what they want as the title ;)