Re: Uploading a file to web server using Lisp



On Feb 5, 10:19 am, "Trastabuga" <lisper...@xxxxxxxxx> wrote:
Could anyone point me the direction how I can implement uploading
files from a web browser to a web server using lisp? Any libraries? Is
CGI the only way to accomplish it? There are lots of materials on how
to do it using PHP but I could nothing for Lisp.

Here's an exmple on how to do it with portableaserve http://
www.cliki.net/Portableaserve (from examples.cl included in the
tarball)

http://paste.lisp.org/display/36419

hth

Nick

;; these two urls show how to transfer a user-selected file from
;; the client browser to the server.
;;
;; We use two urls (/getfile to put up the form and /getfile-post to
;; handle the post action of the form). We could have done it all
;; with one url but since there's a lot of code it helps in the
;; presentation to separate the two.
;;
(publish :path "/getfile-old"
:content-type "text/html; charset=utf-8"
:function #'(lambda (req ent) (getfile-function
req ent "/getfile-got-old")))

(publish :path "/getfile"
:content-type "text/html; charset=utf-8"
:function #'(lambda (req ent) (getfile-function
req ent "/getfile-got")))


(defun getfile-function (req ent posturl)
(with-http-response (req ent)
(with-http-body (req ent)
(html (:head "get file")
(:body
((:form :enctype "multipart/form-data"
:method "post"
:action posturl)
"Let me know what file to grab"
:br
((:input :type "file"
:name "thefile"
:value "*.txt"))
:br
((:input :type "text" :name "textthing"))
"Enter some text"
:br
((:input :type "checkbox" :name "checkone"))
"check box one"
:br
((:input :type "checkbox" :name "checktwo"))
"check box two"
:br
((:input :type "submit"))))))))




Any suggestions are welcome!
Andrew


.



Relevant Pages

  • Re: Uploading a file to web server using Lisp
    ... files from a web browser to a web server using lisp? ... to do it using PHP but I could nothing for Lisp. ... (defun getfile-function (req ent posturl) ...
    (comp.lang.lisp)
  • Re: Uploading a file to web server using Lisp
    ... files from a web browser to a web server using lisp? ... to do it using PHP but I could nothing for Lisp. ... Portableaserve and Hunchentoot. ...
    (comp.lang.lisp)
  • Re: IIS 5.0 Windows Authenticion/NT Challenge Response
    ... I downloaded the WFETCH tool and ran the tool and this is ... Anonymous mode. ... sufficient credentials>to auto-login to the web server, ... rejected, as it>should), and then you will see the web browser attempt to ...
    (microsoft.public.inetserver.iis.security)
  • Re: Directory Transversal
    ... The application that i'm testing has fuctionality that is like a web server in the way that I can make a connection via a web browser and it will send HTML content to the browser that shows the status of a process. ... what does the OPTIONS command tell you? ... Need to secure your web apps NOW? ...
    (Pen-Test)
  • Re: Style question
    ... save this thread anyway for review later. ... If a Common Lisp core dumps its because of a fault in the implementation or maybe a problem with program's Foreign Function logic. ... If the web server encounters error, it can be caught and something can be returned to the web client. ... Determining what all the possible errors in the GUESS program could be indeterminate, putting a general error handler around it is easier, and just as safe. ...
    (comp.lang.lisp)