Upload | upload pictures | no components | source code
<!--#include file= "Upload_5xsoft.inc"-->
<%
Set conn=server.createobject ("Adodb.connection")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("Db.mdb")
Conn.Open ConnStr
'----------------------------------------
function getextendname (filename)
Extname=lcase (filename)
Extname=right (extname,3)
Extname=right (Extname,3-instr (Extname, "."))
Getextendname=extname
End Function
'---------------------------------------------------
'-------------------------------------------------------
function filename ()
Filename=now ()
Filename=replace (filename, "-", "")
Filename=replace (filename, ":", "")
Filename=replace (FileName, "", "")
Filename=filename
End Function
'----------------------------------------------------------
'-------------------------------------------------------------------
Set Upload=new Upload_5xsoft
Set Upfile=upload.file ("Files")
Title=upload.form ("T1")
Info=upload.form ("T2")
If Upfile.filesize>0 and upfile.filename<> "" Then
If InStr ("Jpg,bmp,gif", Getextendname (upfile.filename)) >0 Then
If upfile.filesize<204800 Then
fname=filename& "." &getextendname (Upfile.filename)
Upfile.saveas Server.MapPath ("pic/" &fname)
sql= "INSERT into IMG (title,info,imgpath) VALUES (' + title +" ', ' "+ info +" ', ' "+ fname +") "
Conn. Execute SQL
Conn.close
Response.Write "<script>alert" (' Add picture Success! '); top.location.href= ' index.asp ';</script> '
Else
Response.Write "<script language= ' JavaScript ' > alert (' File upload failed, size exceeded 200k! ');" History.back (); </script> "
End If
Else
Response.Write "<script language= ' JavaScript ' > alert (' File upload failed, its not picture Format! '); History.back (); </script> "
End If
End If
'--------------------------------------------------------