php - Which characters should I escape/sanitize for file names? -


I have to clear some data that will be used in file names. Some data contains empty space and ampersands character What is a function that should be used in a file name (or path) to save or secure the appropriate data? I did not find anyone in the PHP manual's 'Filesystem Function' section.

So, suppose I have to write my function, which characters do I need to escape (or change)?

If you have an opportunity to store the original name in the database, then I will create a file with just a random hash (mt_rand () / Md5 / SHA1). The advantage will be that you do not rely on the underlying OS (character / path length), value or length of user input, and additional file names can be estimated. Probably Base 64 encoding is also an option.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -