0

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

Costique
  • 23,712
  • 4
  • 76
  • 79
Chava
  • 159
  • 1
  • 5
  • 21

1 Answers1

0

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
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 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 Dec 28 '09 at 15:41
  • Then the user account associated with the Java runtime command has not sufficient rights to write the file at the given location. – BalusC Dec 28 '09 at 19:06