curl-users
problem with perl upload form
Date: Thu, 5 Jul 2007 21:17:50 +0100
Hello,
I'm going mad trying to get curl to post a file to a simple upload form.
HTML Page:
<HTML>
<BODY>
<FORM ENCTYPE="multipart/form-data" ACTION="/exchange/upload.pl" METHOD="POST">
<P> Please select a file to upload: <BR/>
<INPUT TYPE="FILE" NAME="uploadfile">
</P>
<P>
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</P>
</BODY>
</HTML>
UPLOAD.PL script:
use strict;
use CGI;
use FileHandle;
my $cgi = new CGI;
my $filename = $cgi->param('uploadfile');
print $cgi->header();
# strip the remote path and keep the filename
$filename =~ m/^.*(\\|\/)(.*)/;
my $saveFile = "C:\\Exchange\\$2";
if ( open(UPLOADFILE, ">$saveFile") ) {
binmode UPLOADFILE;
while(<$filename>) {
print UPLOADFILE $_;
}
print "$filename uploaded successfully.<br>";
}
else {
print "Failed to open $saveFile: $!<br><br>";
}
CURL commands which don't work for me:
1)
curl --ntlm -u domain\username:pswd -F uploadfile=@c:\dir\realfile.txt
http://iisserver/exchange/upload.pl
returns:
Failed to open C:\Exchange\: No such file or directory<br>
2)
curl --ntlm -u domain\username:pswd -F uploadfile=c:\dir\realfile.txt
http://iisserver/exchange/upload.pl
returns:
c:\dir\realfile.txt uploaded successfully.<br> - However only an empty
file gets created in c:\dir\
3)
lots of variations of 1) and 2) all without success.
upload page works fine through browser, but that does not help me,
just confirms I'm missing something.
can anyone save my sanity?
thanks
andy
Received on 2007-07-05