aspose file tools*
The moose likes Servlets and the fly likes take in file from client machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "take in file from client machine" Watch "take in file from client machine" New topic
Author

take in file from client machine

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
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?


Regards
Azrael Noor
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2503
    
    8

We have a FileUpload faq on the JavaRanch.


OCUP UML fundamental and ITIL foundation
youtube channel
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
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

Joined: Jul 14, 2010
Posts: 63


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.


Subhash Kumar
Attitude is everything
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
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

Joined: Jul 14, 2010
Posts: 63
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

Joined: Jul 29, 2010
Posts: 382


this way i am using code
subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63
try using other drives like f:\\files
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
)
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

could *jnlp* help you?
subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63


you are not throwing the real path which you are using check it first.
subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63
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

Joined: Jul 29, 2010
Posts: 382




1 Error is much better than more than one

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
giving whole code

Code in Servlet




in html


subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63
java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream

provide your application this class any how.
Tom Thomas
Greenhorn

Joined: Jun 23, 2003
Posts: 2
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: take in file from client machine