发布文章、或者新闻、或者产品说明,这一类的图片、文字均有的资料,要求的是,根据文章的需要随时插入图片、并且由其自己指定对齐方式。文字进库,图片上传? adddata.php文件的代码: 1 2 3 4 5 6 7 8 9 10 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/fol/php/jrsx/"; //define up pic path 74 $dirname="article"; 75 if(!(chdir($picuppath))) 76 { 77 die("can not change path!"); 78 } 79 if(!(file_exists("$dirname"))) 80 { 81 if(!(mkdir($dirname,0777))) die("can not make dir!"); 82 if(!(chmod($dirname,0777))) die("can not change dir mode!"); 83 } 84 if(!(chdir($dirname))) die("can not change dir!"); 85 $dirpath=$dirname."/"; 86 $imagepath=$picuppath.$dirpath; //path end 87 88 $image=""; 89 $imagename=""; 90 $imagetype=""; 91 $nowtime=time(); 92 93 $imagename=$imagein_name ; //old pic name for db 94 $imagetail=strrchr($imagename,"."); //get pic name type name 95 $imagename=$nowtime.$imagetail; 96 if(!copy($imagein,$imagepath.$imagename)) die("up pic false"); //up pic end 97 //unlink($imagename); //delete pic in remote 98 99 //$image=base64_encode(fread(fopen($imagein,"r"),10000000)); //inset db begin 100 $imagetype=$imagein_type ; 101 $imgtype=$imagetype; 102 unlink($imagein); 103 104 $imgoldname=$imagename; 105 $imgname=$imagename; 106 $imgbody=$image; 107$result =mysql_query("insert into $tb (title,content,date,author,origin,artcloldname,artcltype,artclname) values('$title','$content','$date','$author','$origin','$imgoldname','$imgtype','$imgname')",$link); 108 } 109 else die("请上传论文"); 110}//end of art 111elseif($db=="foljrxt"&&($tb=="ztjz"||$tb=="alfx")){ 112$result =mysql_query("insert into $tb (title,summary,content,date,author,origin) values('$title','$summary','$content','$date','$author','$origin')",$link); 113} 114else{ 115$result =mysql_query("insert into $tb (title,content,date,author,origin) values('$title','$content','$date','$author','$origin')",$link); 116} 117if (mysql_affected_rows()==1) 118{ 119 ?> 120 添加成功,请返回! 121 122 123} 124else 125{ 126 ?> 127 添加不成功,请稍候再试! 128 129 130} 131?> 132 133 134 135 136 add.php文件的内容: 1 2 3 4 5 6 7 8 9if($db=="foljrbd"&&$tb=="cjzt"){ 10?> 11 57 58} 59 60elseif($db=="foljrsx"&&$tb=="pshzl")//beggin of pshzl of foljrsx 61{ 62?> 63 论文上传 64 106 107}//end of pshzl of foljrsx 108 109else 110{ 111?> 112 录入数据 113 180 181} 182?> 183 184 具体的数据表的建立方式可以从执行语句中看到 附:这是我和一个研究生为学校的一个网站写的后台管理程序的处理后台管理上传的东西,不当之处还请指出来 |
|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )
GMT+8, 2024-9-30 05:37 , Processed in 0.243750 second(s), 12 queries , Gzip On, MemCache On.
Powered by Discuz! X3.5
© 2001-2023 Discuz! Team.