cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: problem with perl upload form

From: Alessandro Vesely <vesely_at_tana.it>
Date: Fri, 06 Jul 2007 09:05:54 +0200

Andy Roper wrote:
> Hello,
> I'm going mad trying to get curl to post a file to a simple upload form.
> <FORM ENCTYPE="multipart/form-data" ACTION="/exchange/upload.pl"
> METHOD="POST">
> [...]
> # strip the remote path and keep the filename
> $filename =~ m/^.*(\\|\/)(.*)/;
> my $saveFile = "C:\\Exchange\\$2";
> if ( open(UPLOADFILE, ">$saveFile") ) {

That regex is naive. What if you have no slashes?

> 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

That's correct

> upload page works fine through browser, but that does not help me,
> just confirms I'm missing something.
>
> can anyone save my sanity?

Your Perl script relies on the specific behavior of just one browser.
Sending the full path of the filename exposes too much info about the
client and is not considered good practice.
Received on 2007-07-06