Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > รบกวนด้วยคับ จะส่งค่าไปอีกหน้า เพื่อที่จะเปิดไฟล์ PDF และให้ทำการนับจับนวนดาวโหลด บันทึกลงฐานข้อมูล



 

รบกวนด้วยคับ จะส่งค่าไปอีกหน้า เพื่อที่จะเปิดไฟล์ PDF และให้ทำการนับจับนวนดาวโหลด บันทึกลงฐานข้อมูล

 



Topic : 057830



โพสกระทู้ ( 56 )
บทความ ( 0 )



สถานะออฟไลน์




คือ ได้ทำการ คลิกไปอีกหน้า เพื่อทำการเปิดไฟล์ pdf และตอนคลิก จะให้ทำการบันทึกลงฐานข้อมูล และเอามาแสดงค่าจำนวนคนดาวโหลด

หน้าหลัก

Code
<a href="download.php?id=<?echo $filename=$row['ID']?>&action=downloads" target="_blank" onclick="return confirm('ยืนยันข้อมูล')" onmouseout="MM_swapImgRestore()"onmouseover="MM_swapImage('Image14','','img/b_download002.gif',1)"><img src="img/b_download001.gif" name="Image14" width="103" height="28" border="0" id="Image14" /></a></td>


หน้า ดาวโหลด

Code (PHP)
<?php
// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the connection file:
require('connect.php');

$id=  $_GET['id'];
         
if(isset($_GET['action']))
   {
   $sql=  "update  ebook  set downloads=downloads+1 where id = '$id'";
   mysql_query($sql)   or die ("Update error : $sql");
   }

//readfile($filePath);
else error("This file does not exist!");
/* Helper functions: */
function error($str)
{
	die($str);
}
?>



คือว่ามัน link ไปอีกหน้าหนึ่งและทำการ บันทึกลงฐานข้อมูลแต่ กลับไม่โชว์ไฟล์ pdf ที่ต้องการให้เปิดอะ ไม่รู้ต้องแก้ตรงจุดไหนคับ



Tag : PHP, MySQL, HTML/CSS, Report Others







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-03-26 09:45:11 By : battlev View : 1304 Reply : 3
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (PHP)
header("location:file/document.pdf");



ใช้แบบนี้ได้เลยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-26 15:50:55 By : webmaster
 


 

No. 2



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


คุณส่งมาแค่ id คุณต้องไป select ชื่อไฟล์มาก่อนแล้วเขียนโค๊ด force download

Code (PHP)
$file = "downloads/getfile.pdf";
header("Cache-Control: public");
header("Content-Type: application/pdf");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=" . $file);
header("Content-Length: " . filesize($file));
readfile($file);

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-27 11:51:39 By : PlaKriM
 

 

No. 3



โพสกระทู้ ( 56 )
บทความ ( 0 )



สถานะออฟไลน์


ทำไม่ได้ซักทีคับ

k.mr.win
<?
header("location:file/document.pdf");
?>
แก้ไข
<?php
header("location:/wwwroot/wwwroot/th/upload/webzine/pdf");
?>
มันก็ error
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wwwroot\wwwroot\th\download.php:3)
-----------------------------------
k.PlaKriM

$file = "downloads/getfile.pdf";
header("Cache-Control: public");
header("Content-Type: application/pdf");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=" . $file);
header("Content-Length: " . filesize($file));
readfile($file);

แก้ไข
<?php
$file = "/wwwroot/wwwroot/th/upload/webzine/pdf";
header("Cache-Control: public");
header("Content-Type: application/pdf");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=" . $file);
header("Content-Length: " . filesize($file));
readfile($file);
?>

มันก็ error นะึคับ
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wwwroot\wwwroot\th\download.php:3)

---------------------------------------------------------------------
ผมจนปัญญาเลยนะคับ ลองทำแล้วไม่ได้เลยคับ ตัว header มันต้องระบุ 1 pdf ไปยัง 1 ที่เลยหรือเปล่าคับ แต่ของผม folder /webzine/
มันมี หลาย pdf ด้วยกัน ไม่ค่อยเข้าใจ header จะต้องเขียนยังหรอคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-28 13:50:49 By : battlev
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนด้วยคับ จะส่งค่าไปอีกหน้า เพื่อที่จะเปิดไฟล์ PDF และให้ทำการนับจับนวนดาวโหลด บันทึกลงฐานข้อมูล
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่