[英]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 我正在将jpeg图像压缩为.lep,现在我有一个.exe文件,可以将.lep图像转换回jpeg,我想编写一个简单的jsp文件,在其中我可以即时解码和.lep图像并在浏览器中显示,下面的代码仅适用于IE
<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. ActiveX控件是Microsoft工具包的一部分,因此只能与Internet Explorer一起使用。 To run an
.exe
, generally you make a request to a server, which then sends back the response of the output from the program. 要运行
.exe
,通常需要向服务器发出请求,然后服务器将程序输出的响应发送回去。 Here's how to do it using PHP and AJAX: 使用PHP和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: 在服务器上,位于您的网页所在目录内的名为
run-executable.php
中:
<?php exec("/path/to/exe"); ?>
Make sure PHP has permissions to run this on your server. 确保PHP有权在您的服务器上运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.