uploading a file and form data
- From: willie klein <willie@xxxxxxxxxxxxxx>
- Date: 18 Feb 2010 20:32:09 GMT
Hi all
new to tcl
I have a script that can upload form data to a server doing
[http::geturl $fileUrl -query [http::formatQuery txtType $type
_VIEWSTATE $viewstate _EVENTVALIDATION $eventvalidation ] ]
I can upload a file to the same server, though it rejects it because
there is no form data. doing
[http::geturl $fileUrl -binary true -type "multipart/form-data;
boundary=$bound" -query $outputData
But I have not been able to do both at the same time.
$outputData looks like this
set outputData {}
set bound "-----NEXT-PART-[clock seconds].[pid]"
set fid [ open $invFile r ]
fconfigure $fid -translation binary
set data [ read $fid [ file size $invFile ] ]
close $fid
append outputData "--$bound"
append outputData "\r\nContent-Disposition: form-data; name=\"$field\";
filename=\"[file tail $invFile]\""
append outputData "\r\nContent-Type: application/text"
append outputData "\r\n\r\n$data"
append outputData "\r\n--${bound}--\r\n"
I have tried this:
append outputData [http::formatQuery txtType $type _VIEWSTATE $viewstate
_EVENTVALIDATION $eventvalidation ]
append outputData "\r\n--${bound}--\r\n"
and this
append outputData "$bound\nContent-Disposition: form-data; name=
\"txtType\"\n\n$type\n"
append outputData "$bound\nContent-Disposition: form-data;name=
\"_VIEWSTATE\"\n\n$viewstate\n"
append outputData "$bound\nContent-Disposition: form-data;name=
\"_EVENTVALIDATION\"\n\n$eventvalidation\n"
append outputData "\r\n--${bound}--\r\n"
any sugestions - direction apreciated
.
- Follow-Ups:
- Re: uploading a file and form data
- From: willie klein
- Re: uploading a file and form data
- Prev by Date: Tcl/Tk 8.5.7 supplied with HTTP/1.0 ?
- Next by Date: Re: best option: tk + itcl + sqlite + threads?
- Previous by thread: Tcl/Tk 8.5.7 supplied with HTTP/1.0 ?
- Next by thread: Re: uploading a file and form data
- Index(es):
Relevant Pages
|