PHP is useful for retaining remote files to the server code (including using getid3 to retrieve audio file attributes)

Source: Internet
Author: User
PHP code for saving remote files to the server (including using getid3 to retrieve audio file attributes) & lt; metacharset = UTF-8/& gt; & lt; forpolichod = "post" & gt; & lt; inputname = "url" size = "50" value = "http://www.mgyyw.c PHP for saving remote files to server code (including using getid3 to retrieve audio file properties)



// Require ('audioexif. class. php ');
// $ AE = new AudioExif ([$ charset = 'gbk']);
// $ File = '/path/to/test10000 ';//
// 1. check whether the file is complete (only for wma, mp3 always returns true )//
// $ AE-> CheckSize ($ file );//
// 2. read information. the returned value is an array composed of information. for key name explanations, see the above //
// Print_r ($ AE-> GetInfo ($ file ));//
// 3. write information. The second parameter is a hash array, key-> value. For more information, see the preceding section. mp3 also supports Track.
// Requires that the file path of the first parameter can be written by the program
// $ Pa = array ('title' => 'New title', 'albumtitle' => 'New album name ');
// $ AE-> SetInfo ($ file, $ pa );//

If ($ _ POST ['getid3']) {
Require_once ('./getID3/getid3/getid3.php ');
$ GetID3 = new getID3;

$ FileInfo = $ getID3-> analyze ('temp/101.wma ');
Echo 'playback Time: '. $ FileInfo ['Playtime _ string'].'
';
Echo 'file size: '. $ FileInfo ['filesize'].'
';
Echo 'file name: '. $ FileInfo ['filename'].'
';
Echo 'file suffix: '. $ FileInfo ['Audio'] ['dataformat'].'
';
Echo 'Question: '. $ FileInfo ['tags'] ['asf'] ['alipay'] [0].'
';
Echo 'Songs: '. $ FileInfo ['tags'] ['asf'] ['artlist'] [0].'
';
Echo 'Ratio: '. round ($ FileInfo ['Audio'] ['bitrate']/). 'kbps
';
Print ("
"); 
print_r($FileInfo);
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 );
}



?>

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.