简体   繁体   中英

Lapton image converting to jpeg on fly

I am compressing jpeg images to .lep, now i have .exe file to convert the .lep image back to jpeg, i want to write a simple jsp where i can decode and .lep image on fly and show it on the browser , the below code is working on IE only

<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>

ActiveX controls only work with Internet Explorer, as they're part of Microsoft's toolkit. To run an .exe , generally you make a request to a server, which then sends back the response of the output from the program. Here's how to do it using PHP and AJAX:

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

On the server, in the file which is called run-executable.php within the directory that your web page is located:

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

Make sure PHP has permissions to run this on your server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM