[Gambas-user] Use of Request.Files in gb.web

José Luis Redrejo jredrejo at ...626...
Fri Sep 14 15:34:11 CEST 2007


2007/9/14, Benoit Minisini <gambas at ...1...>:
>
> On vendredi 14 septembre 2007, José Luis Redrejo wrote:
> > Hi, Benoît,
> > Fighting with gb.web and its lack of documentation,
> >  I'm trying to use Request.Files to get an uploaded file,  but I'm not
> able
> > to recover the file.
> > Could you give a few lines of code with an example? or just a tip to can
> go
> > on...
> >
> > Regards.
>
> Of course:
>
> If in your form, you have the following file field:
>
> <form ...>
> ...
> <input type="file" name="filename">
> ...
> </form>
>
> then gb.web will store the uploaded file in the process temporary
> directory,
> and Request.Fields["filename"] will return the path to this temporary
> file.
>
> Of course your form must use method="post", and
> enctype="multipart/form-data".
>
> Is it clearer?
>
>
I must be a little closed minded today.

I'm using this code:

PUBLIC SUB Main()
DIM directorio AS String


  directorio = Request.Path
    Response.Begin

  SELECT CASE directorio
   CASE "/", ""

      PRINT "<p><h3>" & ("Example") & "</h3><p>"
      PRINT "<form action=\"" & Application.root & "/enviar\"
method=\"POST\" enctype=\"multipart/form-data\">"
      PRINT "Archivo de datos: <input name=\"filename\" type=\"file\"><br>"
      PRINT "<input name=\"submit\" type=\"submit\">"
      PRINT "</form>"

   CASE "/enviar", "/enviar/"

      PRINT "sending"
      TRY PRINT "<p>Fields.Count=" & CString(Request.Fields.Count)
      TRY PRINT "<p>Fields[0]=" & Request.Fields[0]
      TRY PRINT "<p>Fields[filename]=" & Request.Fields["filename"]

    END SELECT

Response.End

'----------------
And, after uploading the file, the web browser output is:
sending

Fields.Count=2

Fields[0]=filename
'---------------

So, Request.Fields["filename"] doesn't return anything (in fact it raises an
error), and I don't understand yet the meaning of
http://www.gambasdoc.org/help/comp/gb.web/request/files

So,  it's still pretty unclear (for me, obviously)

Regards



More information about the User mailing list