例子:
http://www.XXX.com/aaa.mp3
我现在想知道这个路径是否有效,请问怎样可以检查出来
谢谢
http://www.XXX.com/aaa.mp3
我现在想知道这个路径是否有效,请问怎样可以检查出来
谢谢
解决方案 »
- php数据库问题
- 求写sscanf的正则表达式
- 急!关于mysql数据库插入的问题!
- 【高分求助】php如何发送带附件的邮件(Windows Server 2003)
- 事务
- 求助。关于xp下面 Apache访问ntfs的权限问题
- 新手求教--在php中带数据库的web网站,对也管理员,和普通用户的权限控制
- 提示:Warning: Undefined variable: grade in D:\flashlong\flash\admin\config.php on line 104
- PHP分页的QueryString问题,每点一次下一页或上一页,get传参变量就会变长一个(图)
- textarea 里面内容换行。怎么获取到是在那里换行?
- php数据编码问题
- 急求省市ip数据库
$head=@get_headers("http://www.XXX.com/aaa.mp3");
if(is_array($head))
{
echo "存在";
}else{
echo "不存在";
}
<?php// AudioExif.class.php// 用PHP进行音频文件头部信息的读取与写入// 目前只支持 WMA 和 MP3 两种格式, 只支持常用的几个头部信息//// 写入信息支持: Title(名称), Artist(艺术家), Copyright(版权), Description (描述)// Year(年代), Genre (流派), AlbumTitle (专辑标题)// 其中 mp3 和 wma 略有不同, 具体返回的信息还可能更多, 但只有以上信息可以被写入// mp3 还支持 Track (曲目编号写入)// 对于 MP3 文件支持 ID3v1也支持ID3v2, 读取时优先 v2, 写入时总是会写入v1, 必要时写入v2//// 用法说明: (由于 wma 使用 Unicode 存取, 故还需要 mb_convert_encoding() 扩展// 返回数据及写入数据均为 ANSI 编码, 即存什么就显示什么 (中文_GB2312)//// require ('AudioExif.class.php');// $AE = new AudioExif;// $file = '/path/to/test.mp3';//// 1. 检查文件是否完整 (only for wma, mp3始终返回 true)// // $AE->CheckSize($file);//// 2. 读取信息, 返回值由信息组成的数组, 键名解释参见上方//// print_r($AE->GetInfo($file));//// 3. 写入信息, 第二参数是一个哈希数组, 键->值, 支持的参见上方的, mp3也支持 Track// 要求第一参数的文件路径可由本程序写入// $pa = array('Title' => '新标题', 'AlbumTitle' => '新的专辑名称');// $AE->SetInfo($file, $pa);//// 版本: 0.1// 作者: hightman// QQ群: 17708754 (非纯PHP进阶交流群)// 时间: 2007/01/25// 其它: 该插件花了不少时间搜集查找 wma及mp3 的文件格式说明文档与网页, 希望对大家有用.// 其实网上已经有不少类似的程序, 但对 wma 实在太少了, 只能在 win 平台下通过 M$ 的API 来操作, 而 MP3 也很少有可以在 unix/linux 命令行操作的, 所以特意写了这个模块
//
// 如果发现 bug 或提交 patch, 或加以改进使它更加健壮, 请告诉我.
// (关于 ID3和Wma的文件格式及结构 在网上应该都可以找到参考资料)
//if (!extension_loaded('mbstring'))
{
trigger_error('PHP Extension module `mbstring` is required for AudioExif', E_USER_WARNING);
return true;
}// the Main Class
class AudioExif
{
// public vars
var $_wma = false;
var $_mp3 = false; // Construct
function AudioExif()
{
// nothing to do
} // check the filesize
function CheckSize($file)
{
$handler = &$this->_get_handler($file);
if (!$handler) return false;
return $handler->check_size($file);
} // get the infomations
function GetInfo($file)
{
$handler = &$this->_get_handler($file);
if (!$handler) return false;
return $handler->get_info($file);
} // write the infomations
function SetInfo($file, $pa)
{
if (!is_writable($file))
{
trigger_error('AudioExif: file `' . $file . '` can not been overwritten', E_USER_WARNING);
return false;
}
$handler = &$this->_get_handler($file);
if (!$handler) return false;
return $handler->set_info($file, $pa);
} // private methods
function &_get_handler($file)
{
$ext = strtolower(strrchr($file, '.'));
$ret = false;
if ($ext == '.mp3')
{ // MP3
$ret = &$this->_mp3;
if (!$ret) $ret = new _Mp3Exif();
}
else if ($ext == '.wma')
你看上面的吧,我是百度到的
if(is_array($head))
{
echo "存在";
}else{
echo "不存在";
}这个方法如果文件不存在,会超级的慢,一直请求下去,咋办
if(is_array($head))
{
echo "存在";
}else{
echo "不存在";
}同意
$head=@get_headers("http://www.XXX.com/aaa.mp3");
if(is_array($head))
{
echo "存在";
}else{
echo "不存在";
}同意