im' trying to make a file based article system
and i want the folders to be my categories and files inside it to be the actual articles. But sometimes i need some special characters in my folder/file name(\/:*?"
,and actually i'm interested just in double quotes and question mark). Is there a way to do the trick...something like &
is in html or something like this. thanks
views:
65answers:
3There are only few special characters which aren't allowed in file names. so keep your own insanitized sequence for those characters. For instance, replace all '?' with '#quest' before creating files and so. Do the reverse when you read them, aint this good? Insanitized means some combination of characters that we don't type usually like '#quest'.
Short answer: Your operating system could support such file names, but it doesn't seem to.
There isn't a simple way for you to do something easy like &
for this. You could store the real filename, or make a conversion table such that something like _____questionmark_____
converted into that symbol or something silly like that, but then you run into problems with that particular string.
Fundamentally though, you should store the title separately from the file itself. A database would be an appropriate location.
At a deeper level, if you're asking a question like this, I think it's safe to say that allowing users to specify filenames on your system is likely to be a large security risk.
I would recommend using a .htaccess
file to pass the "filename" as an argument to your PHP script. Subsequently have the script look up the article in a database lookup table that points to the article file.