This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Uploading files in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Uploading files in JSP" Watch "Uploading files in JSP" New topic
Author

Uploading files in JSP

William Fretts-Saxton
Greenhorn

Joined: Mar 06, 2005
Posts: 11
Hey all,

I've successfully uploaded files, using jsp, on my local web server. I cannot, however, do so to my 3rd-party hosting site (godaddy.com) because I have a java.io.FilePermission problem.

I'm guessing that the fileOut.write class method, when trying to write a file to the server, isn't locating the proper directory where uploads are accetable. Problem is: I don't know how to direct it to the directory. When I upload it to my local web server, it saves it to c:\windows\system32 which is very weird.

Any ideas on how I can find out which directory "fileOut.write" writes to? Am I correct is thinking "fileOut" is the correct class to use?
William Fretts-Saxton
Greenhorn

Joined: Mar 06, 2005
Posts: 11
fileOut declaration:

FileOutputStream fileOut = new FileOutputStream(<file>);
[ March 09, 2005: Message edited by: William Fretts-Saxton ]
William Fretts-Saxton
Greenhorn

Joined: Mar 06, 2005
Posts: 11
Still no luck.

I tried using a File("") and the "getAbsolutePath()" method, which returned "/root".

I then used File("/root") and the "list()" method to return all files and directories in "/root" but I got permission denied.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Why not use an absolute path to the directory?
It may also be that your hosting company has wisely set a security policy prohibiting disk writes from within a webapp.

You might want to check with them to see if this is even allowed.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Fretts-Saxton
Greenhorn

Joined: Mar 06, 2005
Posts: 11
I don't even know what the absolute path. How can I tell where the "php_uploads" directory is, in absolute terms?

If you mean just "/root", I tried that and got permission denied.

FYI,The permissions on the php_uploads directory is 770. Everything else that is created is 755 so it seems to me that this would be the place they would allow uploads. I just don't know how to allow the outside world to upload stuff as the owner or the group.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Uploading files in JSP
 
Similar Threads
How would you design this??
JSP Compilation doubt
Servlet
need urgent help in jsp beans
Eclipse problem regarding M2Eclipse/integrated web server