PHP: How to sanitize uploaded filenames?

后端 未结 6 1906
生来不讨喜
生来不讨喜 2021-01-02 11:32

I have a PHP application.

I allow users to upload files to my web application.

Question: What\'s the best way for me to sanitize the file n

6条回答
  •  清酒与你
    2021-01-02 12:29

    I bet that you also store some information about the file in the database. If this is correct, then you can use the primary key (ID) as a filename on your server and preserve the original filename in the database. This gives you greater flexibility, because you can manipulate the metadata without renaming the actual file.

提交回复
热议问题