1. 2. 3. <%'on error resume next%> 4. <% 5. dim upload,file,formName,formPath,iCount,filename,fileExt,i,mima,password 6. set upload=new upload_5xSoft '建立上传对象 7. 8. name=upload.form("name") 9. formPath="../../uploadpic/"&Request.Cookies("login")("userName")&"/"'上传相对目录 10. userFileName=request.Cookies("login")("userName")'建立企业图片保存目录 11. 12. CreateFolder(Server.MapPath("../../uploadpic/"&userFileName)) '建立企业文件夹 13. CreateFolder(Server.MapPath("../../uploadpic/"&userFileName&"/s")) '建立小图存放路径 14. CreateFolder(Server.MapPath("../../uploadpic/"&userFileName&"/b")) '建立小图存放路径 15. 16. if right(formPath,1)<>"/" then formPath=formPath&"/" 17. 18. for each formName in upload.file '列出所有上传了的文件 19. set file=upload.file(formName) '生成一个文件对象 20. 21. if file.filesize<0 then 22. response.Write("请选择上传的文件") 23. response.end 24. end if 25. if file.filesize>500000 then 26. response.Write("文件不得超过500Kb") 27. response.end 28. end if 29. 30. fileExt=lcase(right(file.filename,4)) 31. if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" then 32. response.Write("只允许上传gif,jPG,png文件!") 33. response.end 34. end if 35. 36. Dim Jpeg 37. FilePath=Server.MapPath("./")'设置上传目录位置 38. FilePath=Req(FilePath &"/"&formPath) 39. 40. Set Jpeg = Server.CreateObject("Persits.Jpeg") 41. If -2147221005=Err then 42. response.Write("没有ASPJPEG组件请安装") 43. Response.End() 44. End If 45. ranNum=int(900*rnd)+100 46. filenamett=file.FileName 47. filenamet=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&fileExt 48. filename=Req(filepath&filenamet) 49. filesize=file.filesize 50. if file.FileSize>0 then '如果 FileSize > 0 说明有文件数据 51. file.SaveAs filename '保存文件 52. else 53. response.redirect "info.asp?info=文件错误!" 54. response.Write("文件错误") 55. response.end 56. end if 57. '图片水印功能开始 58. Jpeg.Open filename 59. Jpeg.Canvas.Font.Color = &HFFFFFF 60. Jpeg.Canvas.Font.Family = "Arial" 'family设置字体 61. Jpeg.Canvas.Font.Bold = True '是否设置成粗体 62. Jpeg.Canvas.Font.Size = 16 '字体大小 63. Jpeg.Canvas.Font.Quality = 2'输出质量 64. Jpeg.Canvas.Print Jpeg.width-150, Jpeg.height-23, "WWW.2007LJFW.COM" 65. 'Jpeg.Save filename'需要水印保留这句即可 66. '图片水印功能结束 67. set file=nothing 68. Jpeg.Open (filename) 69. '开始变更所有文件扩展名为jpg 70. filenamelen=len(filenamet) 71. filenamelen=filenamelen-4 72. filenamet1=filenamet 73. filenamet=left(filenamet,filenamelen) 74. filenamet=filenamet&".jpg" 75. '结束文件名变更 76. 77. '开始判断哪边为长边,以长边进行缩放 78. imgWidth=Jpeg.OriginalWidth 79. imgHeight=Jpeg.OriginalHeight 80. 81. if imgWidth>=imgHeight and imgWidth>=150 then 82. Jpeg.Width=150 83. Jpeg.Height=Jpeg.OriginalHeight/(Jpeg.OriginalWidth/150) 84. end if 85. if imgHeight>imgWidth and imgHeight>200 then 86. Jpeg.Height=200 87. Jpeg.Width=Jpeg.OriginalWidth/(Jpeg.OriginalHeight/200) 88. end if 89. '结束判断 90. 91. 'ImgObj.SaveFile(FilePath & "small_" & filenamet) 92. 'end if 93. 'ImgObj.Free 94. 'Set ImgObj = nothing 95. Jpeg.Sharpen 1, 130 96. Jpeg.Save (FilePath & "/s/"&filenamet) 97. '写入数据库 98. yy=year(date) 99. mm=right("00"&month(date),2) 100. dd=right("00"&day(date),2) 101. idate=yy & "-" & mm & "-" & dd & " " 102. 103. xx=right("00"&hour(time),2) 104. ff=right("00"&minute(time),2) 105. mm=right("00"&second(time),2) 106. itime=xx & ":" & ff & ":" & mm 107. 108. itime=idate&itime 109. 110. photourlb=formPath & filenamet1 111. 'if imgwidth<320 and imgheight<240 then 112. photourls=formPath & "s/"&filenamet 113. 'else 114. 'photourls=photourlb 115. 'end if 116. name=upload.form("name") 117. rs.open "SMT_cp",conn_p,1,3 118. rs.addnew 119. rs("name")=trim(upload.form("name")) 120. rs.update 121. rs.close 122. 123. next 124. 125. set upload=nothing 126. conn.close 127. set conn=nothing 128. 129. conn_p.close 130. set conn_p=nothing 131. response.Redirect("add_products.asp?action=ok") 132. 133. Function Req(Str) 134. If IsEmpty(Str) Then Exit Function 135. Str = Lcase(Str) 136. do 137. A_len=len(Str) 138. Str = Replace(Str,Chr(0),"") 139. Str = Replace(Str,"asp","") 140. Str = Replace(Str,"asa","") 141. Str = Replace(Str,"aspx","") 142. Str = Replace(Str,"cer","") 143. Str = Replace(Str,"cdx","") 144. Str = Replace(Str,"htr","") 145. Str = Replace(Str,"asax","") 146. Str = Replace(Str,"ascx","") 147. Str = Replace(Str,"ashx","") 148. Str = Replace(Str,"asmx","") 149. Str = Replace(Str,"axd","") 150. Str = Replace(Str,"vsdiso","") 151. Str = Replace(Str,"rem","") 152. Str = Replace(Str,"soap","") 153. Str = Replace(Str,"config","") 154. Str = Replace(Str,"cs","") 155. Str = Replace(Str,"csproj","") 156. Str = Replace(Str,"vb","") 157. Str = Replace(Str,"vbproj","") 158. Str = Replace(Str,"webinfo","") 159. Str = Replace(Str,"licx","") 160. Str = Replace(Str,"resx","") 161. Str = Replace(Str,"resou","") 162. Str = Replace(Str,"jsp","") 163. Str = Replace(Str,"php","") 164. Str = Replace(Str,"cgi","") 165. str = Replace(str," ","") 166. str = Replace(str,"%5C","") 167. str = Replace(str,"%2F","") 168. str = Replace(str,"asp","") 169. str = Replace(str,"asa","") 170. str = Replace(str,"cer","") 171. str = Replace(str,"cdx","") 172. str = Replace(str,"mdb","") 173. str = Replace(str,"hrt","") 174. str = Replace(str,"aspx","") 175. str = Replace(str,"php","") 176. str = Replace(str,"jsp","") 177. str = Replace(str,"'","") 178. loop until A_len=len(Str) 179. Req=Str 180. End Function 181. 182. Function CreateFolder(Filepath) 183. Dim fso, f 184. on error resume next 185. Set fso = CreateObject("Scripting.FileSystemObject") 186. if not fso.FolderExists(Filepath) then 187. Set f = fso.CreateFolder(Filepath) 188. set f = Nothing 189. end if 190. set fso = Nothing 191. End Function 192. %>