You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Benjamin Lerman <Be...@ambre.net> on 2005/10/16 14:08:49 UTC

Playing with the file system

 Hi all,

 First of all, I'm not sure what I want to do is the right way to handle
my problem, so all suggestion, even if they are not a response to the
problem asked would be appreciate.

 I'd like to implement the possibility to upload files to my
application. The uploading part is not really the problem as there is a
lot of documentation about it, my problem is: where can I save the files.

 I'd like to put them in the /img directory of my application, but I
cannot find a way to get a real path for this directory. Is there any
way to get it? And what is this real path if the server does not deploy
my application?

 And then my other question is: how can I access the ressource
/img/foo.jpg?

 Thanks in advance.

	Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Playing with the file system

Posted by Larry Meadors <lm...@apache.org>.
I have done this by putting the uploads into a database (in a blob)
then creating a servlet to serve them up.

This has the added benefit of allowing you to easily add additional
info to the image (who uploaded it? when? etc...)

Larry


On 10/16/05, Benjamin Lerman <Be...@ambre.net> wrote:
>  Hi all,
>
>  First of all, I'm not sure what I want to do is the right way to handle
> my problem, so all suggestion, even if they are not a response to the
> problem asked would be appreciate.
>
>  I'd like to implement the possibility to upload files to my
> application. The uploading part is not really the problem as there is a
> lot of documentation about it, my problem is: where can I save the files.
>
>  I'd like to put them in the /img directory of my application, but I
> cannot find a way to get a real path for this directory. Is there any
> way to get it? And what is this real path if the server does not deploy
> my application?
>
>  And then my other question is: how can I access the ressource
> /img/foo.jpg?
>
>  Thanks in advance.
>
>         Benjamin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Playing with the file system

Posted by Tamas Szabo <sz...@gmail.com>.
Hi,

you should probably look at the methods of ServletContext.

I'd like to put them in the /img directory of my application, but I
> cannot find a way to get a real path for this directory. Is there any
> way to get it?


ServletContext.getRealPath(String path)

And then my other question is: how can I access the ressource
> /img/foo.jpg?


ServletContext.getResourceAsStream(String Path)


Tamas

Re: Playing with the file system

Posted by Benjamin Lerman <Be...@ambre.net>.
 Thanks for your answers, it helps me resolved my problem.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org