I need to know how to pass the information about the path of a computer on the client
Let me explain this reason for asking this question - the problem i am haveing with the fopen function in my php download is probley has more to do with any thing is that i need the actaul path of let say for mininete and sake of easy the computer that will be reciving the downloaded viedo file. I think that if no path is given and only the file name then the fopen function thinks it is opening the file or in this case creating a non existing file and in my case needs to be binnary mode. So when i use the fopen funtion the modes need to be either 'ab' or 'wb' but also the path needs to be the correct path of where i want the file to be created - and what i do not want is teh file to be created where the download.php and teh veido is befire i download it.
So getting back to the basic point - and question starting from square one - How do i get the path of where i want the file to exist when i create the file being the viedo - I do realize that i will have to play with the path once i have it passed to the my download.php script which is server sdie script.
I figure there are several ways one could do this - i would like to avoid any java because some browser do not support it and i am looking for a sure fire way so that i will all ways have a vaid path or at least part of one when i pass the path or url to to my server side php script - what i do not want is the path to test tp be empty.
With that said I also do not want the user to have to file put the path in a text box either - I just want the user to click on a link and have this link call the download.php script - which i have no problem doing that but what if any thing can i do to pass the path a vaild path to the down;oad.php - i am looking for ones thoughts and ideas on that.
I have done some reading on the matter and kind of at a loss - i see some postings that indicae to me that there are some issues and cases where a open window might not have a empty server varable ect being passed from the browser so that is why i am asking this to get and idea of one that is a liitle more knowelage about this can give me some insght on taking the right aproach on this. I my self lack a great deal ofit when it comes to this stuff in general but i am leanring fast.
Ok I have inclueded in the bottom of this again my download.php - i think i am on the right track for once any way here it is
<?php
// path to remote file
$ftp_server = '00.00.000.000';
$ftp_user_name = 'username';
$ftp_user_pass = 'password';
$local_file = 'cnbcpvct.wmv';
$remote_file = 'cnbcprofile.wmv';
// open some file to by appedning and mode binary
$handle = fopen($remote_file, 'ab'); // The file does not esit yet until it is downloaded
// 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, $local_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 $local_file to" . $remote_file . "\n";
}
echo "Red Hot Stocks Is Updating";
// close the connection and the file handler
ftp_close($conn_id);
fclose($handle);
?>
Now if you look at the fopen you will see the mode is 'ab' i have done the same with 'wb' also
// open some file to by appedning and mode binary
$handle = fopen($remote_file, 'ab'); // The file does not esit yet until it is downloaded
I have tested the fopen by reading the actual viedo file on the web server and it opens it jsut fine.
So if you look at the $remote_file you will see that it has no path and the path is not the path on the web server but the path where the user is lets call it the cliant.
$remote_file = 'cnbcprofile.wmv';
.
So i need to modify this $remote_file by adding the valid path for the viedo file - cnbcprofile.wmv - now i can give the user the option to change it if he wants.
The other thing and it is only a quetion in passing that is does it matter looking at my download.php server side script if the fopen is before or after the fpt_connect or the ftp_login because maybe part fo the paths to the client and server are setup when all these thing happen happens and my fopen function in the wrong place?
THANKS
Frank H. Shaw
|