cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem with attachment based multiple form!

From: Sanjeev <sunaditya1_at_yahoo.com>
Date: Wed, 11 Dec 2002 23:33:38 -0800 (PST)

HI All!

I'm facing serious problem with submitting attachement
based
form along with other fields.

I'm attaching two files to this mail
1) probDescrition.html ( describing my problem )
2) displayForm.html ( source of problem )

Please go through them.
Hope there IS a way out to do this.

Thank you
Bye
Sanjeev

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

hi,

The Following is the detailed description of the problem


OS : 	Mandrake Linux 8.2 ( Blue Bird ) on i586				
cURL: 	curl-7.10.3-pre1									
Apache: Apache/1.3.23 (Unix)
mysql:  Ver 11.15 Distrib 3.23.46
php:	4.1.2
															

>> After authenticating into the site, we are taken into
a page containing 2 forms.
>> I Attached the re-formatted html page.
>> The second form has the 'file' field.

Here is the process i'm following:

>> Authenticating:

	curl = curl_easy_init();
	if(curl) {
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(curl, CURLOPT_URL, 
				"http://www.yyy.com/qqq/formspage.phtml");
        curl_easy_setopt(curl, CURLOPT_FILE, file);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, mfile);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
				"uid=san&pass=san");
        res = curl_easy_perform(curl);
															

and returns/stores the session.

>> The top form of the fetched page contains a pull down
menu which changes below form according to what we
select from the pull down menu there.

To change below form to the "Software" form, i did,

        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, 
				"DF=Software&continue=Continue");
        res = curl_easy_perform(curl);
															

which worked and returned me the "Software" form
which you see in the attached file.
>> If I ignore the Attachment field I could successfully
submit the page with:

        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, 
				"m_tpc=zzz&m_desc=yyy&m_class=1&frmnum=1&stat=1&continue=Continue");
        res = curl_easy_perform(curl);
															

>> But If I wanted the attachments, i'm not successfull
with any of the following trails:

( The background of this attachments is once we
click on attach file, the file is copied to an
upload dir. and we are returned a session value
along with the same form, along with the
details of the attached file
displayed at the bottom of the form. This way
we can add multiple attachments before giving
a final Submit. i Hope and pray there is a way
to do this with CURL ).

These are the options I've tried::



	1)
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
				"m_file='/tmp/myfile.dat'&attSub=Attach");
        res = curl_easy_perform(curl);
															

No result! The page is actually submitted here
but without any attachments. According to code
if we left any important field blank, the page
returns asking for the input, along with displaying
any of attachments we previously attached.
Here the page appeared, has intructions to fill
in all details, but the Attachment field didnt
show the attachment,neither it was added to upload
dir, as per the backend coding!


2) curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "m_file", CURLFORM_FILE, "/tmp/log.txt", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "m_file", CURLFORM_COPYCONTENTS, "/tmp/log.txt", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "attSub", CURLFORM_COPYCONTENTS, "Attach", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "continue", CURLFORM_COPYCONTENTS, "Continue", CURLFORM_END);

Here in the second step i tried almost all of the
permutations and Combinations, from submitting all
all fields to with/without continue and also
including the form 1 values. Never am I successful.


Also strangely what I observed in verbose is

curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);

formpost is infact submitting the previous
Authentication POSTFIELDS instead of these values
appended to formadd. I cannot disable the authenticaion
for testing, as it is the session that matters to
proceed any further. I did exactly as per the postit2.c
file from the distribution package.

>> Could Some one please help me out of this!
test
Please input all the fields identified by *
My Software
* Topic
* Description
* m Class
* Form ID#?
Yes No
* Stat?
Yes No
File  
Attachments
File Name File Size Mime Type
   test.dat    20 Bytes text/plain

-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
Received on 2002-12-12