Jump to content

i am having trouble with the php fopen function using a WMV viedo file i am


Recommended Posts

The problems i am haveing are two fold and are do to a missunderstanding of something - first the php script is located on a web server and I am wirting  a php script to download a WMV formted file and put it on my desk top computer but my fopen is failing and why - i have tried to simplfy the process by only put in the fopen and then close it after wards. - what i am trying to do is FTP the WMV viedo file to the local computer using a php script located and to be run from a web server.

 

 

 

so how do i modify the fopen so that it know that the file i am opening is to be written on the local computer and not on the web server.

 

 

 

This is the error meassge i am getting

 

 

 

Warning: fopen(cnbcprofile.wmv) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\download.php on line 10

 

 

 

Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\download.php on line 11

 

 

 

 

 

here is the test php script that I am using :

 

 

 

<?php

 

$local_file = 'cnbcprofile.wmv';

 

 

 

// open some file to write to

 

$handle = fopen($local_file, 'wb');

 

fclose($handle);

 

?>

 

 

 

 

 

_________________________________________________________

 

 

 

Note: I removed the actial IP address and username and password from the php script.

 

 

 

below is the full php script

 

 

 

<?php

 

// path to remote file

 

$ftp_server = '00.00.000.000';

 

$ftp_user_name = 'username';

 

$ftp_user_pass = 'password';

 

$remote_file = 'cnbcpvct.wmv';

 

$local_file = 'cnbcprofile.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 you are too stoned and 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 actial errors from the full script!

 

 

 

Warning: fopen(cnbcprofile.wmv) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\download.php on line 10

 

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\download.php on line 32

 

There was a problem while downloading cnbcpvct.wmv tocnbcprofile.wmv Red Hot Stocks Is Updating

 

Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\vhosts\redhotstocks.com\httpdocs\download.php on line 42

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.