与ASP mimetype文件 [英] mimetype file with asp

查看:356
本文介绍了与ASP mimetype文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过使用ASP来获取文件的mime类型?
如果只是有文件路径。

Is there a way to get the mimetype of a file by using asp? If just have the path to the file.

推荐答案

这样做将是采取文件的文件扩展名,查找注册表项的一种可能的方法 HKEY_CLASSES_ROOT \\<文件扩展> 。应该有这个键,使该MIME类型的文件,至少在最流行的文件类型下,内容类型的价值。

One possible way of doing this would be to take the file extension of the file and look up the Registry key HKEY_CLASSES_ROOT\<file extension>. There should be a "Content Type" value under this key that gives the MIME type of the file, at least for the most popular file types.

这假定文件扩展名的文件内容的可靠指标。在Unix上,还有就是文件命令,该命令可以查找幻数内该文件,并可以返回正确的文件类型,即使扩展名是错误的。该实用程序的端口存在于Windows。你也许能够<一个href=\"http://classicasp.aspfaq.com/general/how-do-i-execute-a-dos-command/batch-file/exe-from-asp.html\"相对=nofollow>从ASP执行它并捕获它的输出。

This assumes the file extension is a reliable indicator of the file's contents. On Unix, there is the file command which can look for "magic numbers" inside the file and can return the correct file type even if the extension is wrong. A port of this utility exists for Windows. You might be able to execute it from ASP and capture its output.

这篇关于与ASP mimetype文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆