[racket] "upload file" button in a Racket web server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Aug 1 10:24:55 EDT 2014

There's nothing that a normal Web app can do that Racket can't.
Whatever you see in the UI is just HTML + JS. The exact same HTML and
JS will work in Racket as well. The actual upload code is something
like:

<form action="upload.cgi" enctype="multipart/form-data" method="post">
<input type="file" name="datafile" size="40">
<input type="submit" value="Send">
</form>

And on the server you will get a binding:file object:

http://docs.racket-lang.org/web-server/http.html?q=form%3Afile#%28def._%28%28lib._web-server%2Fhttp%2Frequest-structs..rkt%29._binding~3afile%29%29

The drag&drop into the box sounds to me like it is just done by your
browser when you use a "file" input, as above.

Jay

On Fri, Aug 1, 2014 at 9:35 AM, Andrew Dudash <drewdudash at gmail.com> wrote:
> There's the following.
>
>   #lang web-server/insta
>
>   (require web-server/formlets)
>
>   (define (start req)
>     (send/formlet (file-upload)))
>
> But this doesn't support dragging and dropping images. You can add support
> for that with JavaScript, but I don't think there's anything like it in a
> Racket library. (I'd love to be proven wrong if anyone knows of one.)
>
>
>
> On Thu, Jul 31, 2014 at 10:21 PM, Mitchell Wand <wand at ccs.neu.edu> wrote:
>>
>> Many web pages have an "upload file" button that allows the user to
>> drag&drop a file onto the button, and then hitting the button sends the file
>> to the server.
>>
>> Is there any way of doing this in a Racket web server?  If not, how close
>> can we come?
>>
>> --Mitch
>>
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>



-- 
Jay McCarthy
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

Posted on the users mailing list.