Home > Backend Development > PHP Tutorial > PHP 保留远程文件到服务器代码管用(包括使用getid3获取音频文件属性的用法)

PHP 保留远程文件到服务器代码管用(包括使用getid3获取音频文件属性的用法)

WBOY
Release: 2016-06-13 11:49:33
Original
1502 people have browsed it

PHP 保存远程文件到服务器代码管用(包括使用getid3获取音频文件属性的用法)










// require ('AudioExif.class.php');
// $AE = new AudioExif([$charset = 'GBK']);
// $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);//

if (($_POST['getid3'])){
require_once('./getID3/getid3/getid3.php');
$getID3 = new getID3;

$FileInfo = $getID3->analyze('temp/101.wma');
echo '播放时间:'.$FileInfo['playtime_string'] .'
';
echo '文件大小:'.$FileInfo['filesize'] .'
';
echo '文 件 名:'.$FileInfo['filename'] .'
';
echo '文件后缀:'.$FileInfo['audio']['dataformat'] .'
';
echo '标    题:'.$FileInfo['tags']['asf']['album'][0].'
';
echo '歌    手:'.$FileInfo['tags']['asf']['artist'][0].'
';
echo '比 特 率:'.round($FileInfo['audio']['bitrate']/1000,0).' kbps
';
print("
"); <br>print_r($FileInfo); <br>print("
Copy after login
");
}
if (($_POST['AudioExif'])){
require ('AudioExif.class.php');
$AE = new AudioExif([$charset = 'GBK']);
$file=$_POST['url'];
echo $file;
echo $AE->CheckSize($file);
print_r($AE->GetInfo($file));

}
set_time_limit (24 * 60 * 60);
if (!isset($_POST['submit'])) die();
// folder to save downloaded files to. must end with slash
$destination_folder = 'temp/';

$url = $_POST['url'];
$newfname = $destination_folder . basename($url);
$file = fopen ($url, "rb");
if ($file) {
$newf = fopen ($newfname, "wb");
if ($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );

}
}
if ($file) {
fclose($file);
echo 'OK';
}
if ($newf) {
fclose($newf);
}



?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template