在警报弹出脚本函数运行PHP函数
我有加密方法&上传方法,我点击加密按钮后,我想有,如果我要上传加密后收存箱,该对话框包括,指出弹出对话框是或否。如果不是,我只希望文件被加密,如果是,我希望文件加密并上传到保管箱。在警报弹出脚本函数运行PHP函数
目前我的方法是分隔的,我想通过使用弹出按钮将它们连接在一起。
谢谢!
这是弹出脚本函数:
<script> function confirmDelete(delUrl) {
if (confirm("Do you want to upload to Dropbox?")) {
document.location = delUrl;
}
}
</script>
<a href="javascript:confirmDelete('delete.page?id=1')">Encrypt</a>
如何运行的,如果弹出脚本这个功能点击是吗?
加密形式
<form> <b>Select file to encrypt:</b>
<br>
<label for="file">Filename:</label>
<input type="file" name="file" id="file">
<br>
<input type="submit" value=" Encrypt ">
</form>
上传表单
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <b>Select file to upload:</b>
<br>
<label for="file">Filename:</label>
<input type="file" name="path" id="file"><br>
<input type="submit" name="submit" value=" Upload ">
</form>
回答:
你需要隐藏输入添加到表单区分表单提交类型。
向表单添加onsubmit
处理程序,然后在提交时检查$_POST['action_type']
。
<script type="text/javascript"> function confirmUpload() {
if (confirm("Do you want to upload to Dropbox?")) { // click 'Yes'
document.getElementById('action_type').value = 'upload'
}else{ // click 'No'
document.getElementById('action_type').value = 'encrypt'
}
return true;
}
</script>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" onsubmit="return confirmUpload()">
<b>Select file to upload or encypt:</b>
<br>
<label for="file">Filename:</label>
<input type="file" name="path" id="file"><br>
<input type="submit" name="submit" value=" Upload or Encrypt" >
<input type="hidden" id="action_type" name="action_type" value="" />
</form>
回答:
<script> function confirmDelete(delUrl) {
confirm="Do you want to upload to Dropbox?"
if(confirm) {
document.location = delUrl;
}
}
</script>
<a href="javascript:: void(0);" onclick="return confirmDelete('delete.page?id=1');>Encrypt</a>
这可能工作。
以上是 在警报弹出脚本函数运行PHP函数 的全部内容, 来源链接: utcz.com/qa/263208.html