I have
我有
$tmpname = $file_temp_name;
$filename = $file_name;
$tmppath = "http://" . $_SERVER['SERVER_NAME'] . "/uploads/" . $tmpname;
How can i get its content type from these data..?
如何从这些数据中获取其内容类型..?
1 个解决方案
#1
3
If you are using PHP 5.3 or later, you could use the FileInfo extension:
如果您使用的是PHP 5.3或更高版本,则可以使用FileInfo扩展:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $filename);
finfo_close($finfo);
Hope that helps,
希望有所帮助,
#1
3
If you are using PHP 5.3 or later, you could use the FileInfo extension:
如果您使用的是PHP 5.3或更高版本,则可以使用FileInfo扩展:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $filename);
finfo_close($finfo);
Hope that helps,
希望有所帮助,