当前位置:编程问答 > php >

怎样上传文件并存入数据库,给个例子

答案:if ($add){<br>
if ($picture!=&quot;none&quot;){<br>
$pic_data = addslashes(fread($fp=fopen($picture,&quot;r&quot;), filesize($picture)));<br>
$i_str=&quot;insert into picture (picture,picture_type) values ('$pic_data','$picture_type')&quot;;<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=&quot;insert into index_news (news_date,news_title,news_content,news_link,picture_id,is_new,picture_side,news_show) values &quot;;<br>
$i_str.=&quot;('$date','$news_title','$news_content','$news_link','$picture_id','$is_new','$picture_side','$news_show') &quot;;<br>
if (mysql_query($i_str,$dbconnect)) echo &quot;已添加!&quot;;<br>
}<br>

上一个:date.inc.php3,模拟SQLSERVER的两个函数:dateadd(),datediff()
下一个:apache_1.3.12,php4.0bx,informix安装心得

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,