Re: Copy Function Errors

From: Date: Wed, 16 Jul 2008 20:53:05 +0000
Subject: Re: Copy Function Errors
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-276935@lists.php.net to get a copy of this message
On Wed, Jul 16, 2008 at 4:45 PM, Wei, Alice J. <ajwei@indiana.edu> wrote: >> Hi, >> >> I have a snippet of code here: >> >> shell_exec("tar cvf /var/www/html/test/$id/data.tar >> /var/www/html/test/$id/data"); >> >> $file1="http:/www.mysite.com/test/$id/data.tar"; >> $file2="http://www.mysite2.com/test/$id/.tar"; >> >> copy($file1,$file2); >> >> I got the following error in the access log of the server: >> >> [Wed Jul 16 15:45:57 2008] [error] PHP Warning: >> copy(http://www.mysite.com/test/145/data.tar) [<a >> href='function.copy'>function.copy</a>]: failed to open stream: HTTP wrapper does >> not support writeable connections. in /var/www/html/beam_calculation.php on line 20 >> >> 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? Are you considered a "special student" at the University? -- </Daniel P. Brown> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo.

« previous php.general (#276935) next »