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

José Luis Redrejo jredrejo at ...626...
Fri Sep 14 17:23:56 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?
>


Ok, now it's clear for me (and working):
- You said Fields where you mean Files
- Files don't work unless you get fields first. I.e.:

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

Doesn't work, but this other code works as a charm:
     TRY PRINT "<p>Campos=" & Request.Fields.Count
     TRY PRINT "<p>Campos[filename]=" & Request[Request.Fields[0]]

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

Maybe it's a logical behaviour, but maybe for people like me who are not too
smart that's something to document somewhere ;-)



More information about the User mailing list