• 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

take in file from client machine

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am trying to take file from client machine in server
What to do is?

1) in text box take file path
2) send file path to servlet
3) now?


am i getting wrong or not?

 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a FileUpload faq on the JavaRanch.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am not getting where to make the directory

private static final String DESTINATION_DIR_PATH ="/files";

now where should i make this folder?
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



i am not getting where to make the directory

private static final String DESTINATION_DIR_PATH ="/files";

now where should i make this folder?



save the uploaded file(from client) at some central location for example can be file server
or
make some folder on server machine that will always be available and can be treated as file repository with read write permission.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok now

i have make folder in c: drive

C:\files


Now i have changed that portion of code accordingly



When i try to upload the file
i get beautiful error again and i.e







 
subhash kumar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
make sure that folder c:\files directory should exist
and this directory also should have the writing permission


can you post your code how are you accessing this directory.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


this way i am using code
 
subhash kumar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using other drives like f:\\files
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
)
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could *jnlp* help you?
 
subhash kumar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


you are not throwing the real path which you are using check it first.
 
subhash kumar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

throw new ServletException(DESTINATION_DIR_PATH+" is not a directory");



use here realPath in place of DESTINATION_DIR_PATH

your exception is misleading you because file object is created by realPath but ServletException is thrown by DESTINATION_DIR_PATH
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




1 Error is much better than more than one

 
Azrael Noor
Ranch Hand
Posts: 385
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
giving whole code

Code in Servlet




in html


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

java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream


provide your application this class any how.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The call uploadHandler.parseRequest(request) fails - I get the error that my request is not multipart/form-data.

My jsp:
<form action="attachments" method="post" name="files" enctype="multipart/form-data" >
.....
<input type="file" id="dataFile" name="datafile" size="80" accept="image/gif, image/jpeg, image/png, image/jpg">
....

</form>

When I call request.getContentType, null is returned. It doesn't seem that the header is being set by the enctype parameter.

Any ideas?
 
reply
    Bookmark Topic Watch Topic
  • New Topic