File Upload code , this upload code do not know when I wrote, haha or also take out the bar,
<%
Dim Filename,filepath,filetype,obstream,fso,fod,sql ' defines a variable
Filepath=request. Form ("filename" gets the file path
If Len (filepath) =0 or InStr (filepath, "' <>0 then ' the legality of the path
Response. Redirect ("firstfile.asp?info= file is illegal"
Else
Filename=mid (Filepath,instrrev (filepath, "\" + 1) ' Get filename
Filetype=mid (Filename,instrrev (FileName, ".") +1) ' Get file type
Imagepath=server.mappath ("image"
If InStr (filetype, "jpg" <>0 or InStr (filetype, "gif" <>0 or InStr (filetype, "png" <>0 Then ' judge whether the file we want to upload
Set Fso=server.createobject ("Scripting.FileSystemObject"
Set Fod=fso.getfolder (ImagePath)
For each F in fod.files
F=mid (F,instrrev (f, "\" + 1)
If F=filename then ' determine if the file exists
Response. Redirect ("firstfile.asp?info= file already exists"
End If
Next
Set fso=nothing
Set Obstream=server.createobject ("ADODB.stream"
Obstream.type=1
Obstream.open
Obstream.loadfromfile filepath
Path= "Image\" &filename
If obstream.size<500*1024 Then
Sql= "SELECT * from Jimmy"
Call OPENDB ()
Rs.Open sql,cnn,1,3
Rs.addnew
RS ("Image_path" =path
Rs.update
Call Closedb ()
Obstream.savetofile Server.MapPath (path) ' Upload file
Response. Redirect ("firstfile.asp?info= upload file succeeded"
End If
Obstream.close
Set obstream=nothing
Else
Response. Redirect ("firstfile.asp?info= file is not valid, must be a picture file Jpg,gif,png,"
End If
End If
%>