Forum Moderators: coopster

Message Too Old, No Replies

catching a proper file from remote server please help.

saving video file help

         

abhicool

4:37 am on Jan 17, 2010 (gmt 0)

10+ Year Member



I am having a problem to read file from remote url.
at this stage I have successfully grabbed a video from YouTube and link which is generated is.
$link =
// output [v14.lscache2.c.youtube.com...]

which offers a file to download video.flv

now my problem is i want to save this file to localhost.
I have tried using
$file1 = file("$link?$QUERY_STRING");
$file1 = @implode("", $file1);
// echo "$file1";
echo "$file1"; gives raw data of file

FLV ��� ���� � 8.....

Now, I want to save it on my local drive so that i can convert it by using FFMPEG

Please help me.

I have tried..

$fh = fopen("testvideo.flv", "w");
fwrite($fh, $file1);
fclose($fh);

but unable to write data into file. File remains blank after execuation of code.

Please help me.

script3r

4:49 pm on Jan 17, 2010 (gmt 0)

10+ Year Member



Hello,

First of all, why read the entire file with "file" then "implode"?
Use file_get_contents. It is the recommended way to read entire contents of file into a string.


$contents = file_get_contents( $path )
or die( " ... " );

$fp = fopen( "test.flv", "w" )
or die( " ... " );

if( fwrite( $fp, $contents ) === FALSE ) {
die( " .... " );
}

fclose( $fp );


Make sure you have enough permissions to create a file.

abhicool

6:48 pm on Jan 17, 2010 (gmt 0)

10+ Year Member



I really hate suphp... I am sure that suphp is preventing me to write data into the file.. any idea to write data on suphp enabled servers ?