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 > php code download pdf file โหลดมาแล้วเปิดไม่ได้ ไฟล์เสีย รบกวนด้วยครับ



 

php code download pdf file โหลดมาแล้วเปิดไม่ได้ ไฟล์เสีย รบกวนด้วยครับ

 



Topic : 094700



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



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




This file "download.php"

Code
<?php ob_start(); ?>
<?php require_once('Connections/connashimori.php'); ?>
<?php include("check.php"); ?>
<?php include("header.php");?>


<?php
if($_GET['id']){
$filename = "IMAGES/NEWS/".$_GET['id']; // file to be downloaded

// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache

// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-type: application/pdf");

// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");

/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));

readfile("$filename");
exit();
}


echo'<br>';
echo'<table border="1" width="1000" align="center" cellpadding="0" cellspacing="0" bordercolor="lightblue">';
echo'<tr>';
echo'<td align="center" width="70%" bgcolor="lightblue">FileName</td>';
echo'<td align="center" width="15%" bgcolor="lightblue">Size</td>';
echo'<td align="center" width="15%" bgcolor="lightblue">Upload Date</td>';
echo'</tr>';


$sqlSelectFile = "select * from news where year(created) = '2013' order by created DESC";
$querySelectFile = mysql_query($sqlSelectFile);
while($resultSelectFile = mysql_fetch_array($querySelectFile)){
echo'<tr>';
echo'<td><a href="download.php?id='.$resultSelectFile['pdf'].'">'.$resultSelectFile['headline'].'</td>';
echo'<td align="center">'.number_format(((filesize("IMAGES/NEWS/".$resultSelectFile['pdf'])/1024)/1024),2).' MB. </td>';
echo'<td align="center">'.$resultSelectFile['created'].'</td>';
echo'</tr>';
}
echo'</table>';
?>




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-05-04 14:17:41 By : chubichane View : 2237 Reply : 3
 

 

No. 1



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



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


เปิดไม่ได้ดังรูป

error






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-04 14:20:07 By : chubichane
 


 

No. 2



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



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


จะได้ช่วยดูง่ายๆ

Code (PHP)
<?php ob_start(); ?>
<?php require_once('Connections/connashimori.php'); ?>
<?php include("check.php"); ?>
<?php include("header.php");?>


<?php 
if($_GET['id']){
$filename = "IMAGES/NEWS/".$_GET['id']; // file to be downloaded

// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
// browser must download file from server instead of cache

// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-type: application/pdf"); 

// use the Content-Disposition header to supply a recommended filename and 
// force the browser to display the save dialog. 
header("Content-Disposition: attachment; filename=".basename($filename).";");

/*
The Content-transfer-encoding header should be binary, since the file will be read 
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to 
show a progress meter as a file downloads. The content-lenght can be determines by 
filesize function returns the size of a file. 
*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));

readfile("$filename"); 
exit();
}


echo'<br>';
echo'<table border="1" width="1000" align="center" cellpadding="0" cellspacing="0" bordercolor="lightblue">';
echo'<tr>';
echo'<td align="center" width="70%" bgcolor="lightblue">FileName</td>';
echo'<td align="center" width="15%" bgcolor="lightblue">Size</td>';
echo'<td align="center" width="15%" bgcolor="lightblue">Upload Date</td>';
echo'</tr>';


$sqlSelectFile = "select * from news where year(created) = '2013' order by created DESC";
$querySelectFile = mysql_query($sqlSelectFile);
while($resultSelectFile = mysql_fetch_array($querySelectFile)){
echo'<tr>';
echo'<td><a href="download.php?id='.$resultSelectFile['pdf'].'">'.$resultSelectFile['headline'].'</td>';
echo'<td align="center">'.number_format(((filesize("IMAGES/NEWS/".$resultSelectFile['pdf'])/1024)/1024),2).' MB. </td>';
echo'<td align="center">'.$resultSelectFile['created'].'</td>';
echo'</tr>';
}
echo'</table>';
?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-04 14:27:46 By : chubichane
 

 

No. 3



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



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


ยังแก้ไม่ได้ครับ รอผู้ช่วยเหลืออยู่
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-07 11:43:35 By : chubichane
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : php code download pdf file โหลดมาแล้วเปิดไม่ได้ ไฟล์เสีย รบกวนด้วยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 00
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 อัตราราคา คลิกที่นี่