|
-
Apr 28th, 2006, 07:00 AM
#1
Thread Starter
Frenzied Member
How to read the first 100k of remote mp3 file?
Hi all . could any one show me how i can read the first 100 k of a remote mp3 file but not the whole file. i be happy if an expert show me how.Thanks
-
Apr 28th, 2006, 07:57 PM
#2
Stuck in the 80s
Re: How to read the first 100k of remote mp3 file?
From the manual:
string fread ( resource handle, int length )
fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when up to length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.
Use fopen(string filename, string mode), which returns a resource handle, to open the remote file (assuming that such a feature is enabled within your PHP).
PHP Code:
$fp = fopen('http://remote/file.mp3', 'r');
$data = fread($fp, 100 * 1024);
-
Apr 28th, 2006, 08:23 PM
#3
Thread Starter
Frenzied Member
Re: How to read the first 100k of remote mp3 file?
Many thanks for u reply. I am running php on my localhost server . How i know if it is enabled ? could u tell me how to enable it ?
Furthermore , how i can confirm that the partion of the file is downloaded?where it will be stored? The reason is that i want to use getId3 with that mp3 file and get its tag info.So i be happy if u tell me how i can refrence that partial downloaded file.Thanks
-
Apr 28th, 2006, 08:55 PM
#4
Re: How to read the first 100k of remote mp3 file?
 Originally Posted by tony007
Many thanks for u reply. I am running php on my localhost server . How i know if it is enabled ? could u tell me how to enable it ?
Just test it and see. To enable it, you'd have to configure your PHP and if you don't know how to do that, you probably don't have access to do so.
 Originally Posted by tony007
Furthermore , how i can confirm that the partion of the file is downloaded?where it will be stored? The reason is that i want to use getId3 with that mp3 file and get its tag info.So i be happy if u tell me how i can refrence that partial downloaded file.Thanks
It's stored in $data...
-
Apr 28th, 2006, 08:58 PM
#5
Thread Starter
Frenzied Member
Re: How to read the first 100k of remote mp3 file?
 Originally Posted by kasracer
Just test it and see. To enable it, you'd have to configure your PHP and if you don't know how to do that, you probably don't have access to do so.
It's stored in $data...
Thank u for u reply. I tried it now i get this error :
Warning: fopen(http://www.remotesite.com/song.mp3) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in \getid3\remote3.php on line 5
Fatal error: Call to a member function analyze() on a non-object in \getid3\remote3.php on line 13
Bold parts are line 5 and 11
Code:
<?
if ($fp1 = fopen('http://www.remotesite.com/song.mp3', 'rb')) {
$tempname = tempnam('/tmp', 'foo');
if ($fp2 = fopen($tempname, 'wb')) {
fwrite($fp2, fread($fp, 102400));
fclose($fp2);
}
fclose($fp1);
}
$getID3->analyze($tempname); line 13th
?>
I even tried this but i got error again:
Code:
<?
$fp = fopen('http://www.remoteserver.com/1.mp3', 'r');
$data = fread($fp, 100 * 1024);
$getID3->analyze($data);
?>
Error:
Code:
Warning: fopen(http://www.remoteserver.com/1.mp3 ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in \getid3\remote3.php on line 6
Warning: fread(): supplied argument is not a valid stream resource in \getid3\remote3.php on line 7
Fatal error: Call to a member function analyze() on a non-object in \getid3\remote3.php on line 9
I be happy if u let me know how to fix it.thanks
Last edited by tony007; Apr 28th, 2006 at 09:02 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|