Sql file extension type

后端 未结 4 2047
面向向阳花
面向向阳花 2021-01-04 10:23

What is the sql extension type?
I want to upload to some folder in my server only .sql files.
I know that for txt is text/plain. what is for sql f

相关标签:
4条回答
  • 2021-01-04 10:59

    Find out what return $_FILES['userfile']['type']

    replace echo ... with echo $_FILES['userfile']['type'];

    0 讨论(0)
  • 2021-01-04 11:05

    There is no special MIME type for SQL. Just use application/octet-stream.

    See @Vroo's answer below (application/sql). Since RFC6922 was published, this answer is no longer correct.

    0 讨论(0)
  • 2021-01-04 11:06

    The official answer according to IANA is application/sql. See http://www.iana.org/assignments/media-types/media-types.xhtml and http://tools.ietf.org/html/rfc6922

    However, since lots of people don't bother to read documentation you might also want to accept text/sql, text/x-sql and text/plain.

    0 讨论(0)
  • 2021-01-04 11:13

    There is no way to check if it's an SQL file simply on the basis of MIME-types. SQL-files are text/plain, as others already pointed out. You would have to perform some checks on the incoming file (like running a regex which check's for SQL commands, or even running a parser/checker, if one is available in PHP), if you want to be sure only SQL files are uploaded.

    0 讨论(0)
提交回复
热议问题