I'm sure it
can be done -- anything's possible with enough work. The question is whether it
should be done, and I'm going to argue that the answer is "no". To call this PHP code, you're presumably going to have to recreate the PHP server environment (which would mean setting environment variables in a script) then use
Java's Runtime.exec() method to execute the PHP interpreter from that script, and then recover the input and output streams and communicate back and forth with that process. That seems like a lot of work -- not to mention a slow, inefficient, and fragile way to do things. Why not just use a standard
Java file-upload component?