Home > php教程 > php手册 > 怎样上传文件并存入数据库,给个例子

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

WBOY
Release: 2016-06-21 09:12:55
Original
1000 people have browsed it

上传|数据|数据库

if ($add){

if ($picture!="none"){

$pic_data = addslashes(fread($fp=fopen($picture,"r"), filesize($picture)));

$i_str="insert into picture (picture,picture_type) values ('$pic_data','$picture_type')";

$result=mysql_query($i_str,$dbconnect);

$picture_id=mysql_insert_id();

fclose($fp);

unlink($picture);

}

else{

$picture_id=0 ;

}

$i_str="insert into index_news (news_date,news_title,news_content,news_link,picture_id,is_new,picture_side,news_show) values ";

$i_str.="('$date','$news_title','$news_content','$news_link','$picture_id','$is_new','$picture_side','$news_show') ";

if (mysql_query($i_str,$dbconnect)) echo "已添加!";

}



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template