Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Upload is Not Finding Source File  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1775
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use the following servlet to upload a file from client to server folder. This works when I am testing in development environment and running a local application server. However, when I move it to the production app server I get an error message that the source file cannot be found. It is like the servlet is looking on the server machine itself to find the file.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you do this like five times?The servlet *will* look for the file on the server--it only has access to local files.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66186
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to upload a file, you need to obtain the file from the multi-part request. You can't use File I/O -- of course that will read from the local system. Can you imagine the security nightmare if you could just use File I/O to access any client machine?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which reminds me, Bear, those pictures with the giraffe and the jar of peanut butter... disturbing, yet... strangely fascinating.
 
Steve Dyke
Ranch Hand
Posts: 1775
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:If you want to upload a file, you need to obtain the file from the multi-part request. You can't use File I/O -- of course that will read from the local system. Can you imagine the security nightmare if you could just use File I/O to access any client machine?


I got it to work by changing the FileInputStream to InputStream.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is an "item", anyway? Without knowing things like the types you're trying to act on, it's that much more difficult to help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66186
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, it's not a file, it's a stream from the request.

In the future it might be helpful to let us know what 3rd party libraries you are using.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!