I am trying to integrate matlab with php. So i need to use php to call a matlab function. I am passing file path as argument to the matlab function using exec(). I tried lot of things but couldn't make it work. This is my simple code of php to call function phpcreatefile() in matlab.
<html>
<body>
<form action="" method="post">
Enter a filename <input type="text" name="filepath"><br />
<input type="submit" /><br />
</form>
</body>
</html>
<?php
if(isset($_POST['filepath'])) {
$filename = $_POST['filepath'];
$inputDir = "C:\\matlab_2015\\bin";
$outputDir = "C:\\xampp\\htdocs\\software";
//echo $outputDir;
$command = "matlab -sd ".$inputDir." -r phpcreatefile('".$outputDir."\\".$filename."')";
exec($command);
echo "The following command was run: ".$command."<br/>";
echo $filename." was created in ".$outputDir."<br/>";
}
?>
P.S : I have already switched the safe mode to off by making safe_mode_exec_dir=Off
in php.ini and restarted the xampp.
I tried the command in cmd manually and it works properly.