RE: Copy Function Errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Wei, Alice J. [mailto:ajwei@xxxxxxxxxxx]
> Sent: Wednesday, July 16, 2008 3:46 PM
> To: Robert Cummings
> Cc: php-general@xxxxxxxxxxxxx
> Subject: RE:  Copy Function Errors

---8<--- snip
 
> > Is there something I could do here to allow my file be "copied" to
> the remote server?
> 
> Use the ftp functions.
> 
> Thanks for the tip. I have revised my code to:
> 
> // define some variables
> $local_file = "C:/Inetpub/wwwroot/test/$id/beamdata.tar";
> $server_file = "http://192.168.10.63/test/$id/beamdata.tar";;
> 
> // set up basic connection
> $ftp_server="http://192.168.10.63";;
> $conn_id = ftp_connect($ftp_server);
> 
> // login with username and password
> $ftp_user_name="apache";
> $ftp_user_pass="xxxxx";
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
> 
> // try to download $server_file and save to $local_file
> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
>     echo "Successfully written to $local_file\n";
> } else {
>     echo "There was a problem\n";
> }
> 
> // close the connection
> ftp_close($conn_id);
> 
> I have put this snippet in the local server of where I want the files
> to be copied to. However, I see this on my remote server in the logs:
> 
> 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] "GET
> /beam_calculation.php?id=145&no=16 HTTP/1.1" 200 22 "-" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
> 2.0.50727)"
> 
> Is there something I have missed here?

Alice,

Here are some Wikipedia articles that should give you a good start on
understanding the fundamental differences between the two protocols you
are confusing with each other:

http://en.wikipedia.org/wiki/FTP
http://en.wikipedia.org/wiki/HTTP

HTTP itself does not intrinsically handle file uploads in a
server/client relationship. Web forms that include file uploads
generally have a handler function on the other end, and post files via a
form element.

FTP's main function is the transfer of files (hence [F]ile [T]ransfer
[P]rotocol), and is more in line with what you're trying to do here.

HTH,


Todd Boyd
Web Programmer

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux