Originally posted by Terry Peterson
Originally posted by Daniel Lee
Originally posted by Scott Folley
set filename $args package require TclCurl package require base64 echo filename:$filename set outputDir [ file dirname $filename ] set url "http://10.180.10.130/pdf/pdf.php" set typ "multipart/form-data" set ch [ curl::init ] $ch configure -verbose 1 $ch configure -post 1 $ch configure -timeout 60 $ch configure -url $url -httpheader [ list "Content-Type: $typ" ] $ch configure -httppost [ list name "f" file "$filename" contenttype "text/plain" ] $ch configure -httppost [ list name "submit" contents "Submit Query" ] $ch configure -bodyvar xmlData catch { $ch perform } returnCode if { $returnCode == 28 } { error "Connection timed out waiting for server" } #Format of error:Error: File invalid. $ch cleanup #echo "XMLDATA:$xmlData" set returnData "" if { $xmlData eq "" } { error "The return value was blank" } regexp (.*) $xmlData wasteVar returnData if { $returnData eq "" } { error "Data returned was $xmlData and it is not in the right format" } else { regexp (.*) $returnData wasteVar newFilename regexp (.*) $returnData wasteVar newPDFData } set startText [ string range $newFilename 0 4 ] if { $startText eq "Error" } { error "Webservice could not process file!" } else { set fullName [ file tail $newFilename ] set extension [ file extension $fullName ] set rootName [ file rootname $fullName ] set outputFilename "$rootName$extension" set decodedPDF [ base64::decode $newPDFData ] set fh [ open $outputDir/$outputFilename w ] fconfigure $fh -encoding binary puts -nonewline $fh $decodedPDF close $fh }