upload image.jpg en rebol3, formulaire cgi méthode post

Started by rosanoff on 28-Nov-2015/23:53:48-8:00
Bonjour, je cherche un moyen pour 'uploader' une image jpg en rebol3 avec un formulaire cgi méthode post. Cela fait 3 jours que je travaille dessus sans succès donc je suis preneur de toutes les idées que vous pourriez avoir. Merci par avance et bon dev.
I think Bo got it working here: http://video.respectech.com:8080/jsid/cgi.r
Merci/je regarde ce soir./Cordialement
Hello, it almost works . My original image weighs 13.2ko and upload my picture is cut and weighs 1.26ko . how to have the whole ? thanks in advance.
Can you post your HTML and the complete CGI script (or at least the relevant portions)? What version of R3 are you using, server OS, etc?
bonjour, je travail sous debian8 64b serveur thttpd mon code : #!/etc/r3 -cs R E B O L [title: "CGI GET vs POST"] handle-get: funct [] [ prin [ "Content-type: text/html" crlf crlf <!doctype html> <title> "Rebol 3 CGI Sample: Form" </title> <form method="post"enctype="multipart/form-data"> <input type="file" name="mon_fichier" id="mon_fichier" /><br /> <input type="submit" name="submit" value="Envoyer" /> </form> ] ] handle-post: funct [] [ ; data: to string! read system/ports/input ; fields: parse data "&=" ; value: dehex select fields "field" ;value: replace/all value "+" " " prin [ "Content-type: text/html" crlf crlf <!doctype html> <title> "Rebol 3 CGI Sample: Response" </title> ; "Hello," (join value "!") ] ; debut test data: to binary! read system/ports/input load-multipart: func [ -data [binary!] -/local store name content filetype filename -file-prototype qchars nchars dchars ][ -boundary: copy/part data find data #{0D0A} -store: context [] -file-prototype: context [name: data: type: meta: #[none]] -qchars: #[bitset! 64#{//////v///////////////////////////////////8=}] -nchars: #[bitset! 64#{//////////f///////////////////////////////8=}] -crlf: #{0D0A} -;probe to-string data - -unless parse data [ --some [ ---[ ;(probe 0) ----boundary crlf ;(probe 1) ----(name: content: filemime: filetype: filename: none) ;(probe 2) ----{Content-Disposition: form-data; name=} ;(probe 3) ----{"} copy name to {"} {"} ;(probe 4) ----opt [ -----{; filename=} [ ------{"} copy filename to {"} {"} thru crlf ;(probe to-string filename) ------thru {Content-Type: } copy filetype to crlf ;(probe to-string filetype) -----] ----] ;(probe 5) ----crlf crlf [copy content to boundary | copy content to end] ;(probe content) ;(probe 6) ----( -----if crlf = skip tail content -2 [ ------clear skip tail content -2 -----] -----if all [ ------filename ------not empty? filename -----][ ------write join %/var/www/ad/img/ to-string filename content ------content: filename -----] -----store: make store compose [ ------(to-set-word to-string name) (to-string content) -----] ----) ---] | [boundary "--" to end] ;(probe 99) --] -][ --print "Invalid Multipart Postdata" -] - -store ] load-multipart data ; fin test ] switch get-env "REQUEST_METHOD" [ "GET" [handle-get] "POST" [handle-post] ] je ne comprend pas ce qui ne va pas. merci par avance.

Reply