我有这样的功能:
<script>
function scanToLocalDisk() {
scanner.scan(displayResponseOnPage,
{
"output_settings": [
{
"type": "save",
"format": "pdf",
"save_path": "C:\\xampp\\htdocs\\phps\\scanner\\${TMS}${EXT}"
}
]
}
);
}
function displayResponseOnPage(successful, mesg, response) {
if(!successful) { // On error
document.getElementById('response').innerHTML = 'Failed: ' + mesg;
return;
}
if(successful && mesg != null && mesg.toLowerCase().indexOf('user cancel') >= 0) { // User cancelled.
document.getElementById('response').innerHTML = 'User cancelled';
return;
}
document.getElementById('response').innerHTML = scanner.getSaveResponse(response);
}
</script>
和html这样:
<form class='form-horizontal' role='form' action="../proses/tambahtamu.php" method="POST" >
<button type="button" onclick="scanToLocalDisk();">Scan</button>
<div id="response" ></div>
<button type="submit">Tambah Tamu</button>
</form>
我想问的是;如何使用PHP添加“save_path”:“C:\ xampp \ htdocs \ phps \ scanner \ $ {TMS} $ {EXT}”以添加到数据库?
答案 0 :(得分:0)
您可以像这样添加隐藏字段
<input id="save_path" type="hidden" name="save_path" value="" />
在scanToLocalDisk函数中添加变量
var savePath = "C:\\xampp\\htdocs\\phps\\scanner\\${TMS}${EXT}";
document.getElementById("save_path").value = savePath;
当您的表单发布时,您将在$_POST["save_path"]
变量中获得完整路径。