views:

161

answers:

1

I have write access to /tmp folder of my shared hosting account at godaddy. I want to move uploaded pictures from /tmp folder to my hosting account folder /home/content/x/y/z/xyz/html/pic/ I am trying to move file through jsp with no success. Folder permissions are set to (read write execute 0777). Godaddy support insists that transfer of file is possible. I am totally stuck and need help in this regard.

When I use linux command(mv/cp) I get below exception:

Process p = Runtime.getRuntime().exec("mv /tmp/"+fileName+"  /home/content/x/y/z/xyz/html/pic/ "+fileName);

Error: java.security.AccessControlException: access denied (java.io.FilePermission <> execute)

When I write it through stream I get below exception:

OutputStream bos = new FileOutputStream( "/home/content/x/y/z/xyz/html/pic/"+filename);
bos.write(buffer, 0, bytesRead);

ERROR: java.security.AccessControlException: access denied(java.io.FilePermission/home/content/x/y/z/xyz/html/pic/DSC00061.JPG write

A: 

The first error tells that you're not allowed to execute commandline commands, which is very reasonable. The second error is however not very positive. You could at least try File#renameTo().

File source = new File("/tmp", fileName);
File destination = new File("/home/content/x/y/z/xyz/html/pic", fileName);
source.renameTo(destination);
BalusC
renameTo is also getting following exception:java.security.AccessControlException: access denied (java.io.FilePermission /home/content/x/y/z/xyz/html/pic/DSC00061.JPG write)
Chava
Then the user account associated with the Java runtime command has not sufficient rights to write the file at the given location.
BalusC