Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to include jpg file on server

 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am doing project of shopping cart.. in which admin can log in and add the product to his site.. so how to add jpg file of the product on the server.. for copying image I am using FileInputStream and FileOutputStream. but what path should I give to upload file on the server .. suppose I stored images on web-apps\ShoppingCart(projectName)\Images(folderName).

I am using apache web server..

suppose there is file named Laptop.jpg on my desktop.. and I logged in as an admin. so I am giving path to upload file Images/Laptop.jpg... but its giving me an error
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make use of ServletContext#getRealPath() to convert a relative web path to an absolute file system path which you on its turn can use in File/FileInputStream.
 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you... itzz working
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic