• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

find uploaded file from upload

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm fairly new to programming. Now Im working with java backend and servlets where I will upload a file and display it on a servlet side.And this is surely a stupid question but I just have to ask. I have uploaded the file and it prints the pathname in the console, but when I go to the location I can not find the file. What am I doing wrong? and how can i set a folder as desired area where the files should be uploaded?
Thanks!!

Html code:



Servlet:

 
Sheriff
Posts: 28371
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks to me like your code gets the path of the file from the client machine, but then looks for that file on the server machine instead. And naturally it isn't there.

So that isn't how file uploads work. Your upload servlet can't just store the path where the file came from on the client machine, because it won't be able to access the file from there. It actually has to store the contents of that file (which are part of the upload) somewhere on the server. For more (and better) information have a look at our Servlet FAQ entry FileUpload.

 
Louise Blue
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahhh of course.Thank you very much!!;)
 
I love a good mentalist. And so does this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic