怎样上传文件并存入数据库,给个例子
类别: PHP教程
if ($add){<br>
if ($picture!="none"){<br>
$pic_data = addslashes(fread($fp=fopen($picture,"r"), filesize($picture)));<br>
$i_str="insert into picture (picture,picture_type) values ('$pic_data','$picture_type')";<br>
$result=mysql_query($i_str,$dbconnect);<br>
$picture_id=mysql_insert_id();<br>
fclose($fp);<br>
unlink($picture);<br>
}<br>
else{<br>
$picture_id=0 ;<br>
}<br>
$i_str="insert into index_news (news_date,news_title,news_content,news_link,picture_id,is_new,picture_side,news_show) values ";<br>
$i_str.="('$date','$news_title','$news_content','$news_link','$picture_id','$is_new','$picture_side','$news_show') ";<br>
if (mysql_query($i_str,$dbconnect)) echo "已添加!";<br>
}<br>
if ($picture!="none"){<br>
$pic_data = addslashes(fread($fp=fopen($picture,"r"), filesize($picture)));<br>
$i_str="insert into picture (picture,picture_type) values ('$pic_data','$picture_type')";<br>
$result=mysql_query($i_str,$dbconnect);<br>
$picture_id=mysql_insert_id();<br>
fclose($fp);<br>
unlink($picture);<br>
}<br>
else{<br>
$picture_id=0 ;<br>
}<br>
$i_str="insert into index_news (news_date,news_title,news_content,news_link,picture_id,is_new,picture_side,news_show) values ";<br>
$i_str.="('$date','$news_title','$news_content','$news_link','$picture_id','$is_new','$picture_side','$news_show') ";<br>
if (mysql_query($i_str,$dbconnect)) echo "已添加!";<br>
}<br>
-= 资 源 教 程 =-
文 章 搜 索