2010-05-27 50 views
0

Hai frnds我是新来的PHP其实我在编码面临以下问题请任何人都可以提供解决方案?查询字符串问题,如果我们使用标题

  1. 其实我有一个音频播放器,我展示了一些字dcoument
  2. 如果我点击word文档对应的音频文件应该发挥
  3. 其实当我点击doc文件应该弹出IP与另存为,与我使用一些头码开
  4. 也是我传递的查询字符串在浏览器
  5. 查询字符串不能正常工作,如果我用头

谁能给我一个解决方案,它下面是我的代码我附上

<?php 

$f_name = $_POST["fn"]; 
$id = $_POST["id1"]; 
echo $id; 
//echo "../public_html/sites/default/files/ourfiles/$f_name"; 
$res2=db_query("select * from mt_files where id='".$id."' "); 
$row2=db_fetch_array($res2); 

$job_audio=$row2["audio_name"]; 
//echo $job_audio; 
//$job_audi=explode("/",$job_audio); 
//$job_audio=$job_audi[8]; 
$job_audio= "C:/xampp/htdocs/med/sites/default/files/audio/$job_audio"; 
//$job_audio= "C:/Documents and Settings/swuser/My Documents/$job_audio"; 
//echo $job_audio; 


echo "<object data='$job_audio' type='application/x-mplayer2' width='150' height='45'> 
<param name='src' value='$job_audio'> 
<param name='autoplay' value='true'> 
<param name='autoStart' value='1'> 

</object> "; 


$file = "../mts/sites/default/files/docs/$f_name"; 

if (file_exists($file)) { 
    header('Content-Description: File Transfer'); 
    header('Content-Type: application/octet-stream'); 
    header('Content-Disposition: attachment; filename='.basename($file)); 
    header('Content-Transfer-Encoding: binary'); 
    header('Expires: 0'); 
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
    header('Pragma: public'); 
    header('Content-Length: ' . filesize($file)); 
    ob_clean(); 
    flush(); 
    readfile($file); 
    exit; 
} 

//The download table query goes here put the $f_name in insert into with the //time varible 


?> 
+0

我不明白你的问题。该示例没有显示任何HTTP查询字符串的使用。你应该使用$ _REQUEST而不是$ _POST? – Sjoerd 2010-05-27 07:18:34

回答

3

我不明白,要么,但你不能做

echo ...

调用前标题()函数。

是不是你的问题?

之前的任何头()调用删除任何输出,它会工作...更好