我想把上传文件路径返回到前端保存,但是后台php文件里的js没有执行,前台input标签里的value值一直为空。后台acceptfile.php代码如下:
<?php
if(!isset($_REQUEST['filename']))
{
exit('No file');
}
else{
$upload_path = dirname(__FILE__).'/audio';
date_default_timezone_set("Asia/Shanghai");
$filename = $_REQUEST['filename'].rand(0,10000).date('YmdHis');
$fp = fopen($upload_path."/".$filename.".wav", "wb");
$audiosrc=$upload_path."/".$filename.".wav";
echo "<script language='javascript'>parent.send_form.audiosrc.value='$audiosrc';</script>";
echo "<script language='javascript'>alert('上传成功');</script>";
fwrite($fp, file_get_contents('php://input'));
fclose($fp);
exit('done');
}
?>
前端index.php里form表单:
<form id="send_form" method="post" enctype="multipart/form-data">
...
<input type="hidden" name="audiosrc" id="audiosrc" value="" />
<input type="submit" class="send" id="send" value="提交">
</form>
请问问题出在哪,文件是有保存到相应的文件夹里的,就是路径没法返回到前端form表单里。