cURL / Mailing Lists / curl-users / Single Mail

curl-users

Login and uploading in one session

From: Matti Leino <mle_at_demoefekti.net>
Date: Thu, 31 Mar 2005 01:07:41 +0300

Hi,

I'm quite new to the curl, and I'm trying to find a solution for my
login/upload -problem. There has been quite a lot of talk about these,
but I couldn't find solution for my problem:

I have to upload one file into a webpage, but before I can do that, I
have to authenticate. Problem is, loginpage uses hidden text field, with
php session_id, so it's generated every time I access login page and it
has to remain same when uploading. So here's more detailed description
what I'm trying to do:

Accessing uploadpage, it first prompts login page
http://host.example.org.invalid/?upload_file.php:
<html headers and stuff...>

<form method=post>
<input type=hidden name=session value=<php session_id>
<input type=text name=username>
<input type=password name=passwd>
<input type=submit name=login value=yes>
</form>

<rest of the stuff...>

And after successfull login it opens correct page
http://host.example.org.invalid/?upload_file.php:
<html headers and stuff...>

<form method=post>
<input type=hidden name=session value=<php session_id>
<input type=hidden name=other_random_value value=<random_value_from_page>
<input type=text name=description>
<input type=file name=filename>
<input type=submit name=submit value=yes>
</form>

<rest of the stuff...>

So I have to grab those random values, which are generated when
accessing the page and post those values. And of course, I have to do
two posts in one session.

Is this possible? I have tried to play with options given in man-page,
with no luck. Or am I missing something very simple?

Thanks in advance, every help would be nice. :)

Best regards,
Matti L.

-- 
Matti Leino
mle at demoefekti dot net
Received on 2005-03-31