I am trying to write a PHP script to download a WMV - viedo from my web site - page
Here is my following php script what I am trying to do is build a download script to download from my server using ftp a WMV file which is also stored on the web root of my server also. My server is a windows server if that makes difference?
I am trying to have a web page have a link that calls the download.php script on the server and down load the viedo file with the ext WMV and then have the file if so dirsred payed on the local computer – the reason to do this is to avoid the heavy bandwidth usage of trying to play the viedo across the internet from the web page.
Here is the php script – I have removed the ip address the username and password from this script – I stored the information for now in the top of the script in $varables other then that the script should be intact .
if you have some time see what you see could be the problem ! I think but not shure it has something to do with the fopen and the file being FTP to the local computer being in the WMV format. But not shure?
<?php
// path to remote file
$ftp_server = // '00.00.000.000';
$ftp_user_name = 'username';
$ftp_user_pass = 'password';
$remote_file = 'remote.wmv';
$local_file = 'local.wmv';
// open some file to write to
$handle = fopen($local_file, 'wb');
// set up basic connection
$conn_id = ftp_connect($ftp_server);
if (!$conn_id)
{
echo ' Error could not connent to ftp server <br />';
exit;
}
echo ' connected to ftp server <br />';
// login with username and password
@ $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (!$login_result)
{
echo "Error: Could not log on as <br />";
ftp_quit($conn_id);
exit;
}
echo "Login in was succesful <br />";
// try to download $remote_file and save it to $handle
if (ftp_fget($conn_id, $handle, $remote_file, FTP_BINARY, 0))
{
echo "Red Hot Stocks Is Updating";
echo "successfully written to" . $local_file . "\n";
} else {
echo "There was a problem while downloading $remote_file to" . $local_file . "\n";
}
echo "Red Hot Stocks Is Updating";
// close the connection and the file handler
ftp_close($conn_id);
fclose($handle);
?>
Here are the error messages
If this helps
Warning: fopen(cnbcprofile.wmv) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\downlo ad.php on line 11
Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\downlo ad.php on line 12
connected to ftp server
Login in was succesful
Warning: ftp_fget() expects parameter 2 to be resource, boolean given in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\downlo ad.php on line 34
THANKS
Frank H. Shaw
|