【发布时间】:2016-07-11 11:30:41
【问题描述】:
我的网站上有一个表格 (http://hokuco.com/test/)。它使用 php 创建一个文件夹,但是自从我安装了 javascript 后,我的 php 就无法正常工作。 javascript 重定向到 php 创建的文件夹。具有讽刺意味的是,在我使 javascript 工作之前,php 工作。
关注两个障碍之间的区域,如下所示:
<!--===========-->
index.php:
<?php
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
$src = "./xe7";
$dst = $_POST['foldername'];
recurse_copy($src,$dst);
?>
<link rel="stylesheet" type="text/css" href="style.css" />
<div>
<body onload="timer=setTimeout('removeControls();',3)">
<h1>Drawblog</h1>
<div class="FAQ" style ="box-shadow: 1px 1px 3px rgba(0,0,0,0);">
<a href="#hide1" class="hide" id="hide1">Controls</a>
<a href="#show1" class="show" id="show1">-</a>
<div class="list" style ="box-shadow: 1px 1px 3px rgba(0,0,0,0);">
<!--===========-->
<form method="post" id ="form" action ="index.php">
<input type="text" name="foldername" id ="togl">
<input type="submit" name="submit" value="Create panorama">
<script type="text/javascript">
window.onload = function () {
document.getElementById("form").onsubmit = function () {
var folder = document.getElementById("togl").value;
window.location.href ="http://hokuco.com/test/" + folder + "/toggle.php";
return false;
}
}
</script>
</form>
<!--===========-->
<h3>Or,</h3>
<h2>Login with an access code(the account you just typed into the box above, or a code someone shared with you)</h2>
<input type="text" id="field" />
<button id="submit">Go</button>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript">
document.getElementById("submit").addEventListener("click", function(){
var folder = document.getElementById("field").value;
var url = "http://hokuco.com/test/" + folder + "/index.html";
window.location.href = url;
});
</script>
</div>
</div>
<h1> </h1>
<h1> </h1>
<p>make shocking panoramas in minutes, no account needed</p>
<br/>
<br/>
<br/>
<br/>
<p>special thanks to:</p>
<div id="info"><a href="http://threejs.org" target="_blank">three.js css3d</a> - panorama.</div>
<h5>a hokuco company</h5>
</div>
【问题讨论】:
-
请查看如何创建minimal reproducible example
-
我认为您投反对票的原因可能是您发布的大型脚本...尝试清除所有不相关的代码,以使您的代码 sn-p 更易于阅读.. . 请记住,当您这样做时,您可能会无意中发现问题...
-
当
onsubmit函数返回false时,会阻止表单提交,所以$_POST['foldername']没有设置。
标签: javascript php html forms