|
 |
|
สอบถามการทำlink download file ที่upload ไว้ในmysql |
|
 |
|
|
 |
 |
|
ต้องการผู้รู้ช่วย เรื่องcode download ไฟล์ที่เก็บไว้ในmysql ซึ่งตอนนี้สามารถ uploadลง mysql ได้เรียบร้อยเเล้ว เหลือก้อเเค่การdownload ไฟล์ที่เก็บไว้ในmysql ตอบที่นะครับ ขอบคุณมากมาย
CREATE TABLE binary_data (
id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
description CHAR(50),
bin_data LONGBLOB,
filename CHAR(50),
filesize CHAR(50),
filetype CHAR(50)
);
//ส่วน form uploadครับ
<?php
?>
<html>
<head><title>Store binary data into SQL Database</title></head>
<body>
<?php
if ($submit) {
MYSQL_CONNECT("localhost","root","710389@it");
mysql_select_db("binary_data");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
MYSQL_CLOSE();
} else {
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
</body>
</html>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2010-11-12 13:19:49 2010-11-12 13:29:52 2010-11-12 13:30:18
|
 |
 |
 |
 |
Date :
2010-11-12 13:17:53 |
By :
51035354 |
View :
2209 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|