PHP MSQL การดาวน์โหลดไฟล์เพลง ให้ขึ้นป๊อบอัพมาให้กด save ต้องเขียนยังไงคะ
TT
Date :
2011-07-21 16:44:33
By :
nokz
เหมือนกับตัวนี้เลยครับ
Go to : php คลิกดาวน์โหลดไฟล์ .txt ให้มีบันทึก (Save) แทนการเปิดไฟล์ครับ
view.php
<a href='download.php?name=<?=$Resultr['attach_file']?>' target='_blank'> DOWNLOAD </a>
download
<?
header("Content-Disposition: attachment; filename=\"".$_GET["name"]."\"");
readfile("song/".$_GET["name"]);
?>
Date :
2011-07-21 16:57:18
By :
webmaster
มันขึ้นแบบนี้ค่ะพี่วิน
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\pleng\download_file.php:3) in C:\AppServ\www\pleng\download_file.php on line 4
ประวัติการแก้ไข 2011-07-21 17:11:47
Date :
2011-07-21 17:11:17
By :
nokz
เอา code ทั้งหมดมาดูหน่อยครับ
Date :
2011-07-21 17:23:08
By :
webmaster
หน้าที่โชว์เพลงและมีลิ้งสำหรับดาวน์โหลดค่ะ
Code (PHP)
<?
include ("connect.php");
$SQL = "SELECT * FROM member WHERE user_id = '".$_SESSION['user_id']."' ";
$Query = mysql_query($SQL);
$Result = mysql_fetch_array($Query);
?>
</span>
<div align="center" class="style18">ยินดีต้อนรับ <?=$Result["username"];?> เข้าสู่ระบบค่ะ</div>
</form>
</div>
<div id="Layer4">
<div id="Layer5">
<? include ("connect.php");
$SQLca = "SELECT * FROM webboard_post WHERE question_id = '".$_GET['questionid']."' ";
$Queryca = mysql_query($SQLca);
$Resultca = mysql_fetch_array($Queryca); ?>
<form id="form1" name="form1" method="post" action="saveaddaadmin.php?questionid=<? echo $Resultca['question_id']?>">
<?
include ("connect.php");
$strSQL = "select * from webboard_reply where question_id= '".$_GET[questionid]."' order by reply_id ";
$objQuery = mysql_db_query($db,$strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 7; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$sqlC = "select * from member inner join webboard_reply on member.user_id = webboard_reply.user_id WHERE question_id= '".$_GET[questionid]."' ORDER BY reply_id ASC LIMIT $Page_Start , $Per_Page";
$queryC = mysql_db_query($db,$sqlC);
?>
<p align="left" class="style9">
<?
$SQLr = "SELECT * FROM member inner join webboard_post on member.user_id = webboard_post.user_id where question_id = '".$_GET['questionid']."' ";
$Queryr = mysql_query($SQLr);
$Resultr = mysql_fetch_array($Queryr);
?>
<table width="725" height="33" border="1" class="style9" cellpadding="0" cellspacing="0" bordercolor="#FFFF66" >
<tr>
<td width="552" bgcolor="#FF6600" > :: <? echo $Resultr['subject']?> :: </td>
<td width="167" height="33" bgcolor="#FF6600" > <span class="style17">โหวต / <a href="webboard_addaadmin.php?questionid=<? echo $Resultca['question_id']?>">แสดงความคิดเห็น </a></td>
</tr>
<?
$i++ ;
?>
</table>
<table width="725" height="198" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" bordercolor="#FFCC66" class="style9" >
<tr>
<td width="36" bordercolor="#FFCC66" bgcolor="#000000" b="b"> </td>
<td width="97" height="38" bordercolor="#FFCC66" bgcolor="#000000" b="b"><div align="right"><u>รายละเอียด</u></div></td>
<td width="41" bordercolor="#FFCC66" bgcolor="#000000"> <div align="center">:</div></td>
<td colspan="4" bordercolor="#FFCC66" bgcolor="#000000"><? echo $Resultr['post_detail']?> </td>
</tr>
<tr>
<td bordercolor="#FFCC66" bgcolor="#000000" b="b"> </td>
<td height="77" bordercolor="#FFCC66" bgcolor="#000000" b="b"><div align="right"><u>เพลง</u></div></td>
<td bordercolor="#FFCC66" bgcolor="#000000"><div align="center">:</div></td>
<td colspan="4" bordercolor="#FFCC66" bgcolor="#000000"><embed src="song/<? echo $Resultr['attach_file']?>" width="400" height="32" autostart="false" ></embed>
</td>
</tr>
<tr>
<td bordercolor="#FFCC66" bgcolor="#000000" b="b"> </td>
<td height="27" bordercolor="#FFCC66" bgcolor="#000000" b="b"> </td>
<td colspan="3" bordercolor="#FFCC66" bgcolor="#000000"><u>ชื่อเพลง</u> : <? echo $Resultr['song_name']?></td>
<td colspan="2" bordercolor="#FFCC66" bgcolor="#000000"><u>ศิลปิน</u> : <? echo $Resultr['singer_name']?></td>
</tr>
<tr>
<td height="27" colspan="7" bordercolor="#FFCC66" bgcolor="#000000" b="b"> </td>
</tr>
<tr>
<td bordercolor="#FFCC66" bgcolor="#000000" b="b"> </td>
<td height="27" bordercolor="#FFCC66" bgcolor="#000000" b="b"> <u>โดย</u></td>
<td colspan="2" bordercolor="#FFCC66" bgcolor="#000000"> : </td>
<td width="237" bordercolor="#FFCC66" bgcolor="#000000"><? echo $Resultr['username']?> </td>
<td width="131" bordercolor="#FFCC66" bgcolor="#000000"><span class="style17"><a href='download_file.php?name=<?=$Resultr['attach_file']?>' target='_blank'><< DOWNLOAD >></a></span> </td>
<td width="182" bordercolor="#FFCC66" bgcolor="#000000"> </td>
</tr>
<?
// $i++ ;
// }
?>
</table> </p>
<p align="left" class="style9"><img src="image/line/47931_1.gif" width="334" height="15" /> <img src="image/line/47931_1.gif" width="334" height="15" /></p>
<p align="left" class="style9"> </p>
<p align="center" class="style40">:: ความคิดเห็น ::</p>
<p align="center" class="style40">
<?
// include ("connect.php");
// $i=1;
$i=1;
if($Page>1)
{
$i = ($Per_Page*($Page-1)) + 1 ;
}
while($ObjArray=mysql_fetch_array($queryC))
{
?>
<table width="725" border="0">
<tr>
<?
// $SQLrC = "SELECT * FROM member inner join webboard_reply on member.user_id=webboard_reply.user_id order by reply_id ";
// $QueryrC = mysql_query($SQLrC);
// $ResultrC = mysql_fetch_array($QueryrC);
?>
<td height="28"><div align="center" class="style17"></td>
</tr>
<tr>
<td height="32"><div align="center" class="style17">
<div align="center">
<p class="style9"><? echo $ObjArray["reply_detail"] ?> </p>
<p class="style9"><span class="style43">--------------------------------------------------------------------</span><span class="style43">------------------------</span> </p>
</div>
</div></td>
</tr>
<?
$i++ ;
}
?>
</table>
<div align="center" class="style42"><? $num=mysql_num_rows($queryC);
if ($num==0)
{
echo "ยังไม่มีผู้ร่วมตอบกระทู้หัวข้อนี้" ;
} ?></div>
<p align="left" class="style9"><img src="image/line/47931_1.gif" width="334" height="15" /> <img src="image/line/47931_1.gif" width="345" height="14" /></p>
<p align="left" class="style9">
<?
// $forumid = $_GET['forumid'];
?>
Total :
<?= $Num_Rows;?>
Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&forumid=$forumid'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&forumid=$forumid'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&forumid=$forumid'>Next>></a> ";
}
?>
<p align="center" class="style9">
<p align="center" class="style9">
<p align="center" class="style9">
<label>
<textarea name="reply_detail" cols="40" rows="7" id="reply_detail"></textarea>
</label>
</p>
<p align="center" class="style9">
<label>
<input name="ADD" type="submit" id="ADD" value="ADD" />
</label>
</p>
หน้า download_file.php
Code (PHP)
<?
header("Content-Disposition: attachment; name=\"".$_GET["name"]."\"");
readfile("song/".$_GET["name"]);
?>
Date :
2011-07-21 17:27:33
By :
nokz
Error นี้มีเยอะมากครับ ให้ Save File แบบ UTF-8 With Out BOM
Date :
2011-07-21 20:35:24
By :
webmaster
ลองแล้วค่ะ เซฟตามพี่วินบอกแล้ว แต่ก็ยังไม่ได้ เหมือนเดิมเลย แก้ยังไงดีคะ
Date :
2011-07-22 16:05:56
By :
nokz
หรือไม่ให้เปิดบน Edit Plus ครับ
Date :
2011-07-22 20:55:14
By :
webmaster
Load balance : Server 05