.mp3 Filetype Upload

后端 未结 6 1412
清歌不尽
清歌不尽 2021-01-07 06:31

I\'m working on a PHP upload script which allows .mp3 file uploads amongst others. I\'ve created an array which specifies permitted filetypes, including mp3s, and set a maxi

6条回答
  •  不思量自难忘°
    2021-01-07 07:23

    You should never assume the value in $_FILES[...]['type'] actually matches the type of the file. The client can send any arbitrary string, and it's not checked at all by PHP. See here.

    You'll have to do the work yourself to actually determine what type of file was uploaded, unless you have a good reason not to care about security at all (which you probably don't). PHP provides the fileinfo package by default, which does the heavy lifting for you. See finfo_file().

提交回复
热议问题