Nice code! I want to upload file from ios client to webserver. Any advice 
to extract image file information from client, so that it can be stored in 
server.

On Saturday, February 11, 2012 at 9:45:06 AM UTC+5:30, GGGo wrote:
>
> You need a web server in Go : 
> package main 
>
> import ( 
>         "fmt" 
>         "net/http" 
>         "log" 
>         "io/ioutil" 
> ) 
>
> // hello world, the web server 
> func HelloServer(w http.ResponseWriter, req *http.Request) { 
>         file, handler, err := req.FormFile("file") 
>         if err != nil { 
>                 fmt.Println(err) 
>         } 
>         data, err := ioutil.ReadAll(file) 
>         if err != nil { 
>                 fmt.Println(err) 
>         } 
>         err = ioutil.WriteFile(handler.Filename, data, 0777) 
>         if err != nil { 
>                 fmt.Println(err) 
>         } 
> } 
>
> func main() { 
>         http.HandleFunc("/upload", HelloServer) 
>         err := http.ListenAndServe(":8080", nil) 
>         if err != nil { 
>                 log.Fatal("ListenAndServe: ", err) 
>         } 
> } 
>
> I don't have any example in ajax right now but a simple form in html 
> to post file : 
> <form enctype="multipart/form-data" action="http://localhost:8080/ 
> upload" method="post"> 
>   <input type="file" name="file" /> 
>   <input type="submit" value="upload" /> 
> </form> 
>
> With Ajax is the same process, you need a form in html and ajax to 
> post the form. 
>
> GGGO 
>
> On Feb 10, 11:03 pm, Paddy Foran <foran.pa...@gmail.com> wrote: 
> > I think you're confused. AJAX is a Javascript technology. It doesn't 
> really 
> > apply to Go. I think you probably want the http package, which will let 
> you 
> > make HTTP requests. 
> > 
> > Thanks, 
> > Paddy Foran 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Fri, Feb 10, 2012 at 9:37 PM, DEXTER <djc...@gmail.com> wrote: 
> > > Hi 
> > > How do I upload files using ajax and golang ? 
> > 
> > > Thanks 
> > > Dexter

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to