eyve
eyve

Reputation: 33

How To Pass In Variable from PHP to Java

I have a simple PHP form which allows user to selet a file for image processing as well as a Java program to generate some imagesas output. The PHP will make a copy of the image in a specified folder but I need to pass in the image name from PHP to Java in order for the java program to run for the uploaded file. Is there any way to do it? These are part of my current codes for PHP...

<form method="post" action="imageview.php" enctype="multipart/form-data">
Select Image File to Upload: <input type="file" name="image" />
<br><input type="submit" name="upload" value="Upload File!">
</form>

<?php
if (file_exists("photosmp/".$imagename))
{
    echo $imagename." already exists.";
    echo "It is stored in ".$imagetmpname;
}
else
{
    $newfilename = 'duplicate_'.$imagename;
    move_uploaded_file($imagetmpname,"photosmp/". $newfilename);
    $image = "photosmp/$newfilename";
}
?>

Upvotes: 1

Views: 939

Answers (2)

Hrishikesh Mishra
Hrishikesh Mishra

Reputation: 3433

There are various system command are avalaible to fork a java program, like

  • exec(), system(), pctl etc

You can use these.

Upvotes: 0

anubhava
anubhava

Reputation: 786001

Call your Java program by passing a command line parameter:

echo exec ('java PROG "' . $image . '"'); 

Upvotes: 2

Related Questions