Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] multipart/form-data (nearly done - need help)

From: ryan::christiansen::intellisol::com at: 26-Apr-2001 11:11

Librarian comment

There is a full example of handling multi-part form data here. 

I've been writing a routine to parse POSTed multipart/form-data on my Apache server, but I've run into a problem. The routine parses the string of characters which make up an image file okay, but when I try to assign that string of characters to a variable within an object, REBOL tells me... ** Syntax Error: Invalid string -- {ÿØÿà ** Near: (line 1) object-data: make object-data [file: {ÿØÿà I'm trying to assign the string of characters which make up an image file to a variable named 'file within the object named 'object-data, but it doesn't work. Where am I going wrong? Here is my script... REBOL [] post-data: read %post-data ; read the POSTed data as it exists in a file dump cd-block: [] parse/all post-data [ any [to "Content-Disposition:" copy text to "------" (append cd-block text)] ] cd-input: [] foreach cd cd-block [ parse/all cd [thru {name="} copy text to {"} (append cd-input text)] if find cd "filename" [ parse/all cd [thru {filename="} copy text to {"} (file-path-string: copy text)] file-path-block: parse/all file-path-string {\/"} filename: last file-path-block parse/all cd [thru {Content-Type: } copy text to {^/} (file-mime-type: copy text)] ] parse/all cd [thru {^/^/} copy text to {^/} (append cd-input text)] ] cd-input: head cd-input object-data: make object! [] for x 1 (length? cd-input) 2 [ variable: first cd-input cd-input: next cd-input value: first cd-input make-object-data: reform [rejoin [{object-data: make object-data [} (variable) {: ^{} (value) {^}]}]] do make-object-data cd-input: next cd-input ] make-object-data: reform [rejoin [{object-data: make object-data [filename: ^{} (filename) {^}]}]] do make-object-data make-object-data: reform [rejoin [{object-data: make object-data [file-mime-type: ^{} (file-mime-type) {^}]}]] do make-object-data Ryan C. Christiansen Web Developer Intellisol International 4733 Amber Valley Parkway Fargo, ND 58104 701-235-3390 ext. 6671 FAX: 701-235-9940 http://www.intellisol.com Global Leader in People Performance Software _____________________________________ Confidentiality Notice This message may contain privileged and confidential information. If you think, for any reason, that this message may have been addressed to you in error, you must not disseminate, copy or take any action in reliance on it, and we would ask you to notify us immediately by return email to [ryan--christiansen--intellisol--com]