Posted in PHP onApril 26, 2013
其实问题很简单
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>烟台大学体测</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function show_root(){ //var root = myform.file.value; var root = document.getElementById("file").value; //alert(root); //document.getElementById("root").innerHTML=root; myform.root.value=root; } </script> </head> <body> <form name="myform" method="post" action="upload.php"> <input id="file" type="file" name="file"/> <input id="root" type="hidden" name="root"/> <input type="submit" name="submit" onclick="show_root()"/> </form> </body> </html>
upload.php
<?php echo $_POST["root"];
下面这段js代码就是获得file根目录,然后赋值给hidden类型input,然后就可以交给php or jsp 处理了
<script type="text/javascript"> function show_root(){ //var root = myform.file.value; var root = document.getElementById("file").value; //alert(root); //document.getElementById("root").innerHTML=root; myform.root.value=root; } </script>
input file获得文件根目录简单实现
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@