0

Hey so this is a very simple question, but one I just can't find the answer for. I know this is how you test wether the file you uploaded is indeed an image file:

if($_FILES["file"]["type"] == "image/png")

Just swapping the png with wichever file extension you accept. I just want to know how do I use this statement to test for a file that is an .epub file? What is the first part before the / going to be?

Thanks in advance.

4

4 回答 4

1

只需编写一个简单的上传脚本,$_FILES["file"]["type"]在屏幕上打印并上传所需类型的文件

于 2013-05-18T10:27:41.003 回答
0

type是客户端提供的 MIME 信息。我在互联网上找到了一些相关信息

尝试

($_FILES["file"]["type"] == "epub")
于 2013-05-18T10:32:04.463 回答
0
if (pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION) == "epub") {}

文档: http: //php.net/manual/en/function.pathinfo.php

于 2013-05-18T10:30:03.300 回答
0

好的,所以我编写了一个仅输出文件类型的脚本,输出为“application/octet-stream”

这也有助于测试文件是否为 epub 类型。

于 2013-05-19T08:13:13.500 回答