The Sitelet context has the necessary data. Here is a small example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
type EndPoint =
    // ...
    | [<EndPoint "POST /upload">] UploadFile

[<Website>]
let MyWebsite = Application.MultiPage <| fun ctx action ->
    match action with
    // ...
    | UploadFile ->
        match Array.ofSeq ctx.Request.Files with
        | [| f |] ->
        	f.SaveAs f.FileName // Well, this is unsafe, you should validate the filename, but it's just an example
            Content.Text "Uploaded!"
        | _ ->
        	Content.Text "Must upload a file"
            |> Content.SetStatus (Http.Status.Custom 400 (Some "Bad Request"))
By on 6/6/2016 5:13 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper