|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/thomasjolly1/admin/imageuploadsystem/ |
Upload File : |
<%
'''
'''
<!--#include file="../Connections/dsPets.asp" -->
'''
'''
%>
<!-- #INCLUDE file="incImageLoader.asp" -->
<%
''' You Need This Function
''' You Need This Function
''' You Need This Function
'Strips the punctuation marks and special characters from String
Function stripPunctuation(Name)
Output = Name
Output = Replace(Output, ":", "")
Output = Replace(Output, ";", "")
Output = Replace(Output, ",", "")
Output = Replace(Output, ".", "")
Output = Replace(Output, "/", "")
Output = Replace(Output, "'", "")
Output = Replace(Output, "`", "")
Output = Replace(Output, "~", "")
Output = Replace(Output, "!", "")
Output = Replace(Output, "@", "")
Output = Replace(Output, "#", "")
Output = Replace(Output, "$", "")
Output = Replace(Output, "%", "")
Output = Replace(Output, "^", "")
Output = Replace(Output, "&", "")
Output = Replace(Output, "*", "")
Output = Replace(Output, "(", "")
Output = Replace(Output, ")", "")
Output = Replace(Output, "_", "")
Output = Replace(Output, "-", "")
Output = Replace(Output, "\", "")
Output = Replace(Output, "?", "")
Output = Replace(Output, "<", "")
Output = Replace(Output, ">", "")
Output = Replace(Output, " ", "")
stripPunctuation = Output'Return the value of Output
End Function
''' You Need This Function
''' You Need This Function
''' You Need This Function
''' Capture Record ID
''' Capture Record ID
''' Capture Record ID
if request("id") <> "" then
set rs = server.CreateObject("ADODB.Recordset")
sql = "select * FROM yourtablename WHERE id = " & request("id")
response.write sql
rs.Open sql,dbConn,1
end if
''' End Capture Record ID
''' End Capture Record ID
''' End Capture Record ID
''' START DELETE IMAGE ONLY '''
''' START DELETE IMAGE ONLY '''
if request("action") = "deleteImg" then
'' Remove Image from Server
Set FileSystem = CreateObject("Scripting.FileSystemObject")
varFilePath = Server.MapPath("/images/" & rs("sImg"))
response.write varFilePath
if FileSystem.FileExists(varFilePath) Then
FileSystem.DeleteFile (varFilePath)
end if
sql = "update yourtablename set sImg = null where id = " & rs("id")
dbConn.Execute(sql)
response.redirect "edit.asp?id=" & rs("id") ' redirect if deleted
end if
''' END DELETE IMAGE ONLY '''
''' END DELETE IMAGE ONLY '''
' load object this is required
Set load = new Loader
' calling initialize method
load.initialize
' Get All Data Fields But Not the Image Field
id = load.getValue("id") ''' NEEDED FOR EDIT
sample_field = load.getValue("sample_field")
sImgNew = stripPunctuation(load.getValue("sample_field")) ''' This Renames The File Name To the Sample Field Data
''' If you Don't want a name for the image instead you can use a time stamp
''' sImgNew = stripPunctuation(now)
sImgNew = "image_" & lcase(replace(sImgNew," ", "_"))
'response.write sImgNew & "<br>"
'''' All of this code transfers the file from the local computer to the server. Continue to End Upload Number 1
'''' Start Upload Number 1
'''' Start Upload Number 1
' File binary data
fileData = load.getFileData("sImg")
' File name
fileName = LCase(load.getFileName("sImg"))
'response.write("fileName: " & fileName & "<br>")
'Set the filename
pos = InStr(fileName, ".")
fileFormat = Right(fileName, Len(fileName) - pos)
'response.write("fileFormat: " & fileFormat & "<br>")
setFileNameOne = sImgNew
'setFileNameOne = stripPunctuation(setFileNameOne)
setFileNameOne = setFileNameOne & "." & fileFormat
'response.write("setFileNameOne: " & setFileNameOne & "<br>")
' File path
filePath = load.getFilePath("sImg")
'response.write("filePath: " & filePath & "<br>")
' File path complete
filePathComplete = load.getFilePathComplete("sImg")
'response.write("filePathComplete: " & filePathComplete & "<br>")
' File size
fileSizeOne = load.getFileSize("sImg")
'response.write("fileSize: " & fileSize & "<br>")
' File size translated
fileSizeTranslated = load.getFileSizeTranslated("sImg")
'response.write("fileSizeTranslated: " & fileSizeTranslated & "<br>")
' Content Type
contentType = load.getContentType("sImg")
'response.write("contentType: " & contentType & "<br>")
' No. of Form elements
countElements = load.Count
' Path where file will be uploaded
'''''''''''' *************************** ''''''''''''
'''''''''''' *************************** ''''''''''''
'''''''''''' *************************** ''''''''''''
''' Define the Path to the folder you want the image located
''' Uploading file data
pathToFile = Server.mapPath("/images/") & "\" & setFileNameOne
'response.write("pathToFile: " & pathToFile & "<br>")
'''''''''''' *************************** ''''''''''''
'''''''''''' *************************** ''''''''''''
'''''''''''' *************************** ''''''''''''
''' Define What File Types are allowed to upload
If (fileFormat = "jpg") or (fileFormat = "jpeg") or (fileFormat = "gif") Then
''' Define Minimum File Size to Upload and Maximum
If fileSizeOne > 250 and fileSizeOne < 200001 Then ' 200001 = 201K... This can be changed to any number
fileUploaded = load.saveToFile("sImg", pathToFile)
Else
setFileNameOne = ""
End If
Else
setFileNameOne = ""
End If
'''' End Upload Number 1
'''' End Upload Number 1
'''' End All of this code transfers the file from the local computer to the server.
''' Update Database '''
''' Update Database '''
''' Update Database '''
set rs = server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM yourtablename where id = " & id
rs.Open sql, dbConn,adOpenDynamic,adLockOptimistic
''' Your Fields
rs("sample_field") = sample_field
''' End Your Fields
''' Update Image Name To Database
if fileSizeOne > 250 and (fileFormat = "jpg") or (fileFormat = "jpeg") or (fileFormat = "gif") and fileSizeOne < 200001 Then
' 200001 = 201K... This can be changed to any number
rs("image_field_in_database") = setFileNameOne
end if
rs.Update
response.redirect "index.asp"
''' Update Database '''
''' Update Database '''
''' Update Database '''
%>