2016-08-01 83 views
0

我壓縮jpeg圖像爲.lep, 現在我有.exe文件將.lep圖像轉換回jpeg,我想寫一個簡單的jsp,我可以解碼和.lep飛圖像,並將其顯示在瀏覽器上,下面的代碼工作在IE僅Lapton圖像轉換爲jpeg飛

<html> 
<head> 
<script type="text/javascript"> 

    function foo() { 
     console.log("Testing"); 
     var WshShell = new ActiveXObject("WScript.Shell"); 
     var oExec = WshShell.Exec("D:\lepton.exe D:\img.lep"); 

     var strOutput = oExec.StdOut.ReadAll(); 
     console.log(strOutput); 

     document.getElementById("img1").src = "D:\img.jpg"; 
    } 
</script> 
</head> 
<body> 
     <button onclick="foo()">Click me</button> 
     <img id="img1" alt="Smiley face" > 
</body> 
</html> 

回答

0

ActiveX控件只在Internet Explorer工作,因爲他們是微軟的工具包的一部分。要運行一個.exe,通常你向服務器發出一個請求,服務器然後發送程序輸出的響應。下面介紹如何使用PHP和AJAX來做到這一點:

$.ajax({ 
    type: "GET", 
    url: 'run-executable.php', 
    success: function(data){ 
     alert(data); 
    } 
}); 

在服務器上,這被稱爲是您的網頁所在的目錄內run-executable.php文件中:

<?php exec("/path/to/exe"); ?> 

確保PHP有權限在你的服務器上運行它。

+0

我該怎麼做同樣的使用jsp/java –