Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

take in file from client machine

 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • 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?

 
Jan Cumps
Bartender
Posts: 2586
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a FileUpload faq on the JavaRanch.
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • 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?
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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: 384
  • Mark post as helpful
  • send pies
  • 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: 63
  • Mark post as helpful
  • send pies
  • 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: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this way i am using code
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using other drives like f:\\files
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
)
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could *jnlp* help you?
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


you are not throwing the real path which you are using check it first.
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




1 Error is much better than more than one

 
Azrael Noor
Ranch Hand
Posts: 384
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
giving whole code

Code in Servlet




in html


 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream

provide your application this class any how.
 
Tom Thomas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic