Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

upload file from perl script

Status
Not open for further replies.
Joined
Dec 31, 2005
Messages
2
Location
IT
#!/perl

use strict;
use warnings;
use Socket qw(:DEFAULT :crlf);
use IO::Socket::INET;

my $content;
my $file = "file.zip";
my $size = (-s $file);
my $target = '
my $socket = IO::Socket::INET->new(
PeerAddr => ' PeerPort => '80',
Proto => 'tcp',
Type => SOCK_STREAM ) or die "Couldn't connect! $!\n";


syswrite $socket, "POST $target HTTP/1.0".$CRLF;
syswrite $socket, "Accept: */*".$CRLF;
syswrite $socket, "Accept-Language: en".$CRLF;
syswrite $socket, "Connection: Keep-Alive".$CRLF;
syswrite $socket, "User-Agent: Mozilla/4.0".$CRLF;
# syswrite $socket, "Content-type: application/octet-stream".$CRLF;
syswrite $socket, "Content-length: $size".$CRLF;
syswrite $socket, "$CRLF";

open(READ, "<$file") || die "$!\n";
binmode(READ);
while( read(READ,$content,4096) )
{ syswrite $socket, $content; }
close(READ);

print <$socket>;
close $socket;

Hi! I’m Italian and I’d like to make the upload of a file from Client to Server using Perl script written below, but I can’t make it work because the server tells me no file has been selected from the form
 
you probably want to use a form to select a file from the users hard drive to upload. What you have is:

my $file = "file.zip";

try putting in the path to a real file on your hard drive and see if that works for testing:

my $file = "c:/path/to/file.zip";
 
Without the use of HTML Form, you could use the FTP module and just move the file from one server to second.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top