This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

problem with upload file using common file upload servlet

 
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good afternoon,
I am having problem of saving an image to the /WebContent/images/ folder in my server. I think i may have missed something important in my codes , and i wonder if you all have any solution for it.

Below are my jsp code and java code








Thanks for all of your help.

Tom
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would start by finding information about the problem. Do error messages appear? Where? What do they say? That sort of thing. Just posting a bunch of code with no information about the failure mode isn't very helpful to anybody.
 
minhdung tran
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
sorry for missing the information to the problem. The code did not give me any error but it did not work as it should.
I think i may miss important component since in the code, i would like it to store the image at the /WebContent/upload folder in the server, but the image was not there when i ran it.

Thanks.
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But here's where you write the file:

I see you have debugging code elsewhere, but I don't see any debugging code here to see whether that fileName variable does what you want.
 
minhdung tran
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,

Sorry for not making myself clear. I don't know how to display the path of the file name variable



it should be at the /WebContent/Upload/image.gif as it indicated earlier in the context root and the setRepository




But it did not appear so. I think i miss some important point in my code

[code = java]
File saveFile = new File("/"+fileName);


[/code]


Thanks.
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

minhdung tran wrote:I don't know how to display the path of the file name variable...



Wouldn't that be



?
 
minhdung tran
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning,
Thanks for your help. I displayed it and it gave me the path to my file system which resided on the C drive, not the server
path as i would like the image to be stored which is under myApp/WebContent/Upload/.

Also the program ran without any error but the image never store there myApp/WebContent/Upload/.


I don't know what i did wrong. Please help me if you could.

Thanks alot!

Tom
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!