找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 网络编程 PHP 查看内容

解决图随机上传,不限量,定位置,与文章进库同步完成

2009-12-21 17:47| 发布者: admin| 查看: 60| 评论: 0|原作者: 仙之剑缘

发布文章、或者新闻、或者产品说明,这一类的图片、文字均有的资料,要求的是,根据文章的需要随时插入图片、并且由其自己指定对齐方式。文字进库,图片上传?
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

12
13
14
18
19
20
38
39
40
45
46
47
51
52
53
54
55

15

请选择需要增加内容的专题:


16

 


17
金融报道>>财经专题>>
21
37

41
42
43
44

48

 


49

建立新的专题


50
 

56

57 58}
59
60elseif($db=="foljrsx"&&$tb=="pshzl")//beggin of pshzl of foljrsx
61{
62?>
63

论文上传


64

65

66
67
68
73
74
75
80
81
82
87
88
89
90
93
94
95
102
103
论文标题:
69
70 作者:
71
72

76

论文简介:
77
78


79

83
论文:
84
85

86

91
  

92

96

97
98  
99
100

101

104

105

106107}//end of pshzl of foljrsx
108
109else
110{
111?>
112

录入数据


113

114

115
116
117
122
123 124{
125?>
126
127
132
133 134 }
135?>
136
137
142
143
144
149
150 151{
152?>
153
154
159
160 161 }
162?>
163
164
167
168
169
176
177
文章标题:
118
119 作者:
120
121

128

简短介绍:
129
130


131

138

文章内容:
139
140


141

145
出处:
146
147

148

155
图片:
156
157

158

165
  

166

170

171
172  
173
174

175

178

179

180181}
182?>
183
184
具体的数据表的建立方式可以从执行语句中看到
附:这是我和一个研究生为学校的一个网站写的后台管理程序的处理后台管理上传的东西,不当之处还请指出来

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏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.

返回顶部