thaiall logomy background
coding : download.php.
my town
Source : Perl | PHP | ASP | JSP | HTML | HTML5 | JavaScript | Java | COBOL | C++ | MS Access | VBNet | VB | Python | โค้ดดี
File : download.php. ID : 7103
Skin : Default | Sons-of-obsidian | Sunburst | Highlighter | Full
<? 
/*
ปรับปรุง : 2549-06-01 
ประกอบด้วย uploadpage.htm, uploadprocess.php และ download.php
Source from http://php.dreamwerx.net/forums/viewtopic.php?t=6
Download script.. streams data from a mysql database, thru the webserver to a client browser 
*/
if (isset($_GET["id"])) { 
$Storage_IP = "localhost"; 
$Storage_Port = 3306; 
$Storage_User = "root"; 
$Storage_Passwd = ""; 
$Storage_DB = "test"; 
$connectto = $Storage_IP . ":" . $Storage_Port; 
if (!$linkid = @mysql_connect($connectto, $Storage_User, $Storage_Passwd)) { 
die("Unable to connect to storage server!"); 
} 
if (!mysql_select_db($Storage_DB, $linkid)) { 
die("Unable to connect to storage database!"); 
} 
$nodelist = array(); 
// Pull file meta-data 
$SQL = "select * from file where id = " . $_GET["id"]; 
if (!$RES = mysql_query($SQL, $linkid)) { 
die("Failure to retrive file metadata"); 
} 
if (mysql_num_rows($RES) != 1) { 
die("Not a valid file id!"); 
} 
$FileObj = mysql_fetch_object($RES); 
// Pull the list of file inodes 
$SQL = "SELECT id FROM filedata WHERE masterid = " . $_GET["id"] . " order by id"; 
if (!$RES = mysql_query($SQL, $linkid)) { 
die("Failure to retrive list of file inodes"); 
} 
while ($CUR = mysql_fetch_object($RES)) { 
$nodelist[] = $CUR->id; 
} 
// Send down the header to the client 
Header ( "Content-Type: $FileObj->datatype" ); 
Header ( "Content-Length: " . $FileObj->size ); 
Header ( "Content-Disposition: attachment; filename=$FileObj->name" ); 
// Loop thru and stream the nodes 1 by 1 
for ($Z = 0 ; $Z < count($nodelist) ; $Z++) { 
$SQL = "select filedata from filedata where id = " . $nodelist[$Z]; 
if (!$RESX = mysql_query($SQL, $linkid)) { 
die("Failure to retrive file node data"); 
} 
$DataObj = mysql_fetch_object($RESX); 
echo $DataObj->filedata; 
} 
} else { 
echo "<form action=download.php method=get><input name=id value=1><input type=submit></form>"; 
} 
?>
จำนวน : 55 บรรทัด
าษาเฮชทีเอ็มแอล (HTML = HyperText Markup Language) คือ ภาษาคอมพิวเตอร์ที่ออกแบบมาเพื่อใช้ในการสร้างเว็บเพจที่เรียกดูผ่านทางเว็บเบราว์เซอร์ (Web Browser) เริ่มพัฒนาโดย ทิม เบอร์เนอรส์ ลี (Tim Berners Lee) ในปัจจุบัน HTML ล่าสุดคือ รุ่น 5 เป็นมาตรฐานหนึ่งของ ISO ซึ่งจัดการโดย World Wide Web Consortium (W3C) ในปัจจุบัน ทาง W3C ผลักดัน รูปแบบของ HTML แบบใหม่ ที่เรียกว่า XHTML รุ่นแรกคือ 1.0 (ม.ค.2543) ซึ่งมีโครงสร้างเป็นแบบ XML (eXtensible Markup Language)
าษาพีเอชพี (PHP Language) คือ ภาษาคอมพิวเตอร์ประเภทโอเพนท์ซอร์ท (Open Source Computer Language) สำหรับพัฒนาเว็บเพจแบบไดนามิก เมื่อเครื่องบริการได้รับคำร้องจากผู้ใช้ก็จะส่งให้กับ ตัวแปลภาษา ทำหน้าที่ประมวลผลและส่งข้อมูลกลับไปยังเครื่องของผู้ใช้ที่ร้องขอ ในรูปเอชทีเอ็มแอล ภาพ หรือแฟ้มดิจิทอลอื่นใด ลักษณะของภาษามีรากฐานคำสั่งมาจากภาษาซี เป็นภาษาที่สามารถพัฒนาให้ใช้งานแบบโต้ตอบกับผู้ใช้ได้
ตัวอย่าง Hello World
ปรับปรุงโปรแกรม source.pl : 2565-07-24
rspsocial
Thaiall.com