douyou8266 2012-01-09 10:52
浏览 87
已采纳

从php调用matlab exe不能正常工作

I have compiled a matlab script into a standalone win app and also a console app. The script can be called from the command line using image_process pic1.png. The exe runs and produces a string as a result. No I want to deploy it in php. I have added a folder to my main website directory called uploads. I need to run php to call the matlab exe to run on the images inside this folder.

Now I go to my PHP script. I define my uploads directory :

define("UPLOAD_DIRECTORY","./uploads"); // defines the uploads directory

then I add the path to my image processor: define("IMAGE_PROCESSORE",dirname(dirname(FILE))."/image_process.exe");

at last I configure my process like :

case "process":
    $res=array();
    $pic=isset($_REQUEST["pic"])?trim($_REQUEST["pic"]):"";
    if($pic==""){
        echo "No picture name is passed";
        exit();
    }
    exec(IMAGE_PROCESSORE.' "'.realpath(UPLOAD_DIRECTORY).'" '.$pic,$res);
    //exec(IMAGE_PROCESSORE." ".$pic,$res); // this one if I define the image_process.exe inside the uploads folder
    echo"<pre>";
    print_r($res);
    echo"</pre>";
break; 

So when I call my php like :

localhost/mysitename/phpresponse.php?act=process&pic=pic1.png

I will get no output, but If I run

localhost/mysitename/phpresponse.php?act=process&pic=c:\xampp\htdocs\mysitename\uploads\pic1.png

The matlab compiled file will run and execute

I am really confused, I did try many things but with no luck...

  • 写回答

2条回答 默认 最新

  • drebew5059 2012-01-09 19:24
    关注

    I did find a solution. I have made the script call 2 arguments and then instead of using exec i used passthru to execute the compiled matlab script. I don`t know why exactly it worked but at least it did :-)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办