Hi Guilers,

The following works fine for plain text files but fails with Word
documents, PDFs, PNG files and no doubt other (binary?) file types.

This error msg, followed by the contents of the file, is dumped on
stderr each time:

 string contains #\nul character: "\x0d
 Content-Disposition: form-data; name=\"File-Upload\"; 
filename=\"eap_logo.png\"\x0d
 Content-Type: image/png\x0d
 \x0d
 .
 .


---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<

 (use-modules (www cgi))

 [...]

 (let* ((upload (cgi:upload "File-Upload"))
        (props-alist (object-property upload #:guile-www-cgi))
        ;;(object-property ...) is deprecated
        (upload-fname (transform-string
                       (assoc-ref props-alist #:filename)
                       #\  #\_)))
   (with-output-to-file (string-append USER-UPLOAD-DIR upload-fname)
     (lambda ()
       (display upload)))))

---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<

How should I go about getting uploaded binary files out of memory and
onto disk?

Any help/advice/pointers much appreciated.

Seb

P.S. 'Writing' rather than 'displaying' the uploaded file makes no
     difference (and is not what I want).

-- 
Emacs' AlsaPlayer - Music Without Jolts
Lightweight, full-featured and mindful of your idyllic happiness.
http://home.gna.org/eap



Reply via email to