[Seaside] get the full path of a file when using a WAFile Component

Lukas Renggli renggli at gmail.com
Mon Dec 18 20:48:12 UTC 2006

> > You can't, basically because the standard disallows you to get the
> > full path (otherwise that would be a big security leak). THere are
> > still some old and buggy browser around, that provide the full path,
> > but you can't count on that.
> I read that as the full path to the file on the server-side. For
> example, in PHP the file is uploaded to: $_FILES['userfile']['tmp_name']
> and the original name (without path) would be in:
> $_FILES['userfile']['name'].
> Since you didn't mention anything about this Lukas, I'm guessing there
> is no file server-side with Seaside, just the data held in an object. If
> that's the case, then I guess you just open an output stream and write
> out the data to a file of your choosing William.

Aha, ok I see. Seaside doesn't save the uploaded file anywhere
automatically, that's up to the developer to decide where to put it.
Maybe you want to save it to the file-system, maybe you want it in a
database, maybe you want to mail it somewhere, ... it is up to you.

>  > SECOND : How could I create a WAFile class object using only the
> fullPath of a file ?
> I guess you'd just set the content: to an opened file-stream. Any
> experienced smalltalkers know better?

Yeah, try something like (assuming that file is an instance of WAFile):

stream := FileDirectory default fileNamed: file fileName.
[ stream binary; nextPutAll: file contents ]
   ensure: [ stream close ]

Then you have stored your file in the directory with your image.
Probably you should change 'FileDirectory default' to a different
subdirectory, to avoid accidental overriding of your image.


Lukas Renggli

More information about the Seaside mailing list