uploading a file and form data



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
.



Relevant Pages

  • Re: uploading a file and form data
    ... I can upload a file to the same server, though it rejects it because there is no form data. ... $outputData looks like this set outputData ... fconfigure $fid -translation binary ...
    (comp.lang.tcl)
  • Re: uploading a file and form data
    ... I have a script that can upload form data to a server doing ... I can upload a file to the same server, ... $outputData looks like this ... fconfigure $fid -translation binary ...
    (comp.lang.tcl)