PHP retains remote file-to-server code (including using GETID3 to get audio file attribute usage)

Source: Internet
Author: User
PHP saves remote files to server code (including using GETID3 to get audio file attributes)



Require (' AudioExif.class.php ');
$AE = new Audioexif ([$charset = ' GBK ']);
$file = '/path/to/test.mp3 ';//
1. Check that the file is complete (only for WMA, MP3 always returns TRUE)//
$AE->checksize ($file);//
2. Read the information, return the value of the array consisting of information, the key name explanation see above//
Print_r ($AE->getinfo ($file));//
3. Write information, the second parameter is a hash array, key-value, supported see above, MP3 also supports track
The file path that requires the first parameter can be written by this program
$pa = Array (' title ' = ' new title ', ' albumtitle ' = ' new album name ');
$AE->setinfo ($file, $PA);//

if (($_post[' getid3 ')) {
Require_once ('./getid3/getid3/getid3.php ');
$getID 3 = new GetID3;

$FileInfo = $getID 3->analyze (' temp/101.wma ');
Echo ' Play Time: '. $FileInfo [' playtime_string ']. '
';
echo ' File size: '. $FileInfo [' filesize ']. '
';
echo ' filename: '. $FileInfo [' filename ']. '
';
echo ' file suffix: '. $FileInfo [' Audio '] [' DataFormat ']. '
';
Echo ' title: '. $FileInfo [' tags '] [' asf '] [' album '][0]. '
';
Echo ' singer: ' $FileInfo [' tags '] [' asf '] [' Artist '][0]. '
';
echo ' bit rate: '. Round ($FileInfo [' Audio '] [' bitrate ']/1000,0). ' Kbps
';
Print ("


Print ("
");
}
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 Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.