|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with coding question ( ftp_get ).
Hi.
I am able to transfer some programs with this app. but not all. Here are my two php files: <code> <?php $name = $_POST['name']; $pass = $_POST['pass']; $directory = $_POST['dir']; if( $name != "xxx" || $pass != "xxx" ) { header( "Location: test3.html" ); } else { echo "<html><body bgcolor=\"black\" text=\"white\">"; echo "<form method=post action=\"test7.php\">"; $files = array(); chdir( $directory ); echo "Currently in " . getcwd() . "<br/>"; $handle = opendir( $directory ); while( $filename = readdir( $handle ) ) { if ( $filename == "." ) { // Skip.. } else if ( $filename == ".." ) { // Skip.. } else { $files[] = $filename; } } closedir($handle); sort( $files ); // Output results echo "<select name=\"file\">"; foreach( $files as $name ) { echo "<option value=\"$name\">$name</option>"; } echo "</select><br/><br/>"; echo "Remote file:<br/>"; echo "<input type=\"text\" name=\"remote\"><br/>"; echo "<font size=2><i>Note: Clobbers remote files</i></font>.<br/><br/>"; echo "<input type=submit value=\"Upload file\">"; echo "</form></body></html>"; } ?> </code> <code> <?php $local_file = $_POST['file']; $remote_file = $_POST['remote']; $directory = $_POST['dir']; define( ID, "xxx" ); define( PW, "xxx" ); // connect to FTP server $conn = ftp_connect("xxx"); if( $conn ) { echo "Successfully connected!<br/>"; } else { echo "Unable to connect to remote server<br/>"; } // log in with username and password $login = ftp_login($conn, ID, PW ); // upload file $transfer = ftp_put( $conn, "$remote_file", "$directory\\$file", FTP_ASCII ); if( $transfer ) { echo "Transfer successful<br/>"; } else { echo "Unable to upload file<br/>"; } ftp_quit( $conn ); ?> </code> I have uploaded .java and .pl files but ( for some reason ), the following file fails: <code> #!/usr/bin/perl -w use strict; use IO::Socket::INET; local $| = 1; my $ID; my $PW; my $port = 8500; my $client; my $server = new IO::Socket::INET( LocalPort => $port, Type => SOCK_STREAM, Listen => 5, Proto => 'tcp', Reuse => 1, ) or die "Couldn't construct server on port: $port : $!\n"; $client = $server->accept(); print $client "ID:"; $ID = <$client>; print "I received $ID\n"; </code> Any help would be most appreciated. Thanks. |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > Help with coding question ( ftp_get ). |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|