分类: Mysql/postgreSQL
2008-05-30 10:50:37
以下为引用的内容: // store.php3 - by Florian Dittmer ?> // 如果提交了表单,代码将被执行: if ($submit) { // 连接到数据库 // (你可能需要调整主机名,用户名和密码) MYSQL_CONNECT( "localhost", "root", "password"); 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 " This file has the following Database ID: $id"; } ?> |
以下为引用的内容: // getdata.php3 - by Florian Dittmer // 调用方法: getdata.php3?id= if($id) { // 你可能需要调整主机名,用户名和密码: @MYSQL_CONNECT( "localhost", "root", "password"); @mysql_select_db( "binary_data"); $query = "select bin_data,filetype from binary_data where id=$id"; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,0, "bin_data"); $type = @MYSQL_RESULT($result,0, "filetype"); Header( "Content-type: $type"); echo $data; }; ?> |