请教一个php ajax上传问题
来源:百度知道 编辑:UC知道 时间:2024/07/16 14:05:01
这是一个上传文件的东西,原本只给父窗口返回1和2,但是我想让他再多返回一个上传成功后的文件地址,几番修改无果,请大侠帮忙:
<?php
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$result = 0;
$target_path = $destination_path . basename( $_FILES['myfile']['name']);
$fileurl = $target_path
if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
<script language="javascript" type="text/javascript">
alert(<?php echo $fileurl; ?>);
//window.parent.stopUpload(<?php echo $result; ?>,<?php echo $target_path; ?>);
</script>
补充: index.html javascripts 脚本
<script language="javascript" type="text/javascript">
<!--
function startUpload(){
document.getElementById('f1_upload_process').style.visibility =
<?php
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$result = 0;
$target_path = $destination_path . basename( $_FILES['myfile']['name']);
$fileurl = $target_path
if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
<script language="javascript" type="text/javascript">
alert(<?php echo $fileurl; ?>);
//window.parent.stopUpload(<?php echo $result; ?>,<?php echo $target_path; ?>);
</script>
补充: index.html javascripts 脚本
<script language="javascript" type="text/javascript">
<!--
function startUpload(){
document.getElementById('f1_upload_process').style.visibility =
你给出的程序不完整,无法作答。
的确
代码不全
最好整个php脚本页面,和html执行页面,以及js脚本页面.一起放上来.
如果太多.
可以去phpchina.com注册一个账号.那上面有许多高手.
你定义的ajax头呢?