• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts multipart saveDir

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

i saw that struts by default upload the file into the project temp

by example : i put the destination here :


the file get uploaded here :



instead of :



in result i cant see the picture uploaded in eclipse project tree folder

Regards


 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krasic wrote:
i saw that struts by default upload the file into the project temp



It does not upload a file into the project temporary directory. It (meaning Apache Commons File Upload) uploads the file to the servlet container's temporary directory. Note that the Struts documentation states "Uploaded files should be processed or moved by your Action class to ensure the data is not lost." so you should not be looking in the temp directory anyway.
Most applications I am aware of either upload the file to a "flat file" database (i.e. a directory structure created from identifying data so the file can be located later) or a "real" SQL database (as a BLOB).
 
Ivan Krasic
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:

Ivan Krasic wrote:
i saw that struts by default upload the file into the project temp



It does not upload a file into the project temporary directory. It (meaning Apache Commons File Upload) uploads the file to the servlet container's temporary directory. Note that the Struts documentation states "Uploaded files should be processed or moved by your Action class to ensure the data is not lost." so you should not be looking in the temp directory anyway.
Most applications I am aware of either upload the file to a "flat file" database (i.e. a directory structure created from identifying data so the file can be located later) or a "real" SQL database (as a BLOB).



what i have done is create a mysql column called picturename (string) which store only the name of the picture
the idea is when submit the form i concatenate the id of the categorie and date and save the that value into the picturestring name
and then the uploaded file goes by default to /img/categorie folder

so when listing the categorie i should just put the picturename value between img tag

using this function


 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to do two things:
1. put the file somewhere you can reliably access it. As I have pointed out earlier, the temp directory is not reliable.
2. create some way to recover the file. I usually make an action that takes the appropriate arguments and reference that action in an IMG tag.
 
Ivan Krasic
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:You have to do two things:
1. put the file somewhere you can reliably access it. As I have pointed out earlier, the temp directory is not reliable.
2. create some way to recover the file. I usually make an action that takes the appropriate arguments and reference that action in an IMG tag.



i dont want it to put into temp : by default goes that

is there a way to get realPath without temp ?

mean
G:\workspace\Struts2\WebContent\admin\img\categorie

instead of
G:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Struts2\img\categorie

i use
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A deployed application knows nothing about the source project it was deployed from. You are thinking of your application as built in to Eclipse and not as a stand-alone application.
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic