发布文章、或者新闻、或者产品说明,这一类的图片、文字均有的资料,要求的是,根据文章的需要随时插入图片、并且由其自己指定对齐方式。文字进库,图片上传?
adddata.php文件的代码:
1<html>
2<head>
3<title>增加数据</title>
4<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
5</head>
6
7<body bgcolor="#FFFFFF">
8
9
10<?
link=mysql_pconnect(]11@$link=mysql_pconnect("localhost","root","rpass007") or
12die ("登陆服务器失败,请稍候再试");
13mysql_select_db($db);
14$date=date('Y-m-d H:i:s');
15if((($db=="foltyx"&&$tb=="wlg_master")||($db=="foljrbd"&&$tb=="tpxw"))||($db=="foljrxt"&&($tb=="shpx"||$tb=="tswl")))//for tyx jrbd jrxt
16{
17 if(chop($imagein)!="none")
18 {
19 $picuppath="/home/fol/php/admin/"; //define up pic path
20 $dirname="picup";
21 if(!(chdir($picuppath)))
22 {
23 die("can not change path!");
24 }
25 if(!(file_exists("$dirname")))
26 {
27 if(!(mkdir($dirname,0777))) die("can not make dir!");
28 if(!(chmod($dirname,0777))) die("can not change dir mode!");
29 }
30 if(!(chdir($dirname))) die("can not change dir!");
31 $dirpath=$dirname."/";
32 $imagepath=$picuppath.$dirpath; //path end
33
34 $image="";
35 $imagename="";
36 $imagetype="";
37 $nowtime=time();
38
39 $imagename=$imagein_name ; //old pic name for db
40 $imagetail=strrchr($imagename,"."); //get pic name type name
41 $imagename=$nowtime.$imagetail;
42 if(!copy($imagein,$imagepath.$imagename)) die("up pic false"); //up pic end
43 $size=getimagesize($imagename); //get size array,for now in uppic,so just imagename else dirpaht
44 $imgwidth=$size[0];
45 $imgheight=$size[1];
46 $imgsize=$size[3];
47 unlink($imagename); //delete pic in remote
48
49 $image=base64_encode(fread(fopen($imagein,"r"),10000000)); //inset db begin
50 $imagetype=$imagein_type ;
51 $imgtype=$imagetype;
52 unlink($imagein);
53
54 $imgoldname=$imagename;
55 $imgname=$imagename;
56 $imgbody=$image;
57if($db=="foljrbd"&&tb=="tpxw"){//there is no summary in tpxw of foljrbd,so
58$result =mysql_query("insert into $tb (title,content,date,author,origin,imgoldname,imgtype,imgname,imgwidth,imgheight,imgsize,imgbody) values('$title','$content','$date','$author','$origin','$imgoldname','$imgtype','$imgname','$imgwidth','$imgheight','$imgsize','$imgbody')",$link);
59}
60else{//tpxw of foljrbd
61$result =mysql_query("insert into $tb (title,summary,content,date,author,origin,imgoldname,imgtype,imgname,imgwidth,imgheight,imgsize,imgbody) values('$title','$summary','$content','$date','$author','$origin','$imgoldname','$imgtype','$imgname','$imgwidth','$imgheight','$imgsize','$imgbody')",$link);
62}
63 }
64 else die("请上传图片");
65}//end of pic or pic with no summary
66elseif($db=="foljrbd"&&$tb=="cjzt"){//beggin of cjzt of fol jrbd
67$result =mysql_query("insert into $tb (title,content,date,author,origin,topic) values('$title','$content','$date','$author','$origin','$topic')",$link);
68}//end of cjzt of fol jrbd
69elseif($db=="foljrsx"&&$tb=="pshzl")//for jrsx
70{
71 if(chop($imagein)!="none")
72 {
73 $picuppath="/home