Prev: Tcl/Tk 8.5.7 supplied with HTTP/1.0 ?
Next: Looking for ideas for reproducing a Tk 8.4 interface under Tk 8.5
From: willie klein on 18 Feb 2010 15:32 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
From: willie klein on 18 Feb 2010 16:13 willie klein <willie(a)pdfsystems.com> wrote in news:Xns9D239E0AB135Ewilliepdfsystemscom(a)74.209.136.97: > 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 > I'm a little further now with: set fileField "fupImporter" 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 "\nContent-Disposition: form-data; name=\"$fileField\"; filename=\"[file tail $invFile]\"\n\n$data" 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" It gets the form data but not the file.
From: Zbigniew Diaczyszyn on 19 Feb 2010 02:14
willie klein schrieb: > willie klein <willie(a)pdfsystems.com> wrote in > news:Xns9D239E0AB135Ewilliepdfsystemscom(a)74.209.136.97: > >> 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 >> > I'm a little further now with: > set fileField "fupImporter" > 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 "\nContent-Disposition: form-data; > name=\"$fileField\"; filename=\"[file tail $invFile]\"\n\n$data" 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" > > It gets the form data but not the file. Try putting the file-data form as the last form-data field |