%@ Language=VBScript %>
<%
' *************************************************************************************
' Change the value of the variable below to the pathname
' of a directory with write permissions, for example "C:\Inetpub\wwwroot\.."
Dim directoryToCheck
'directoryToCheck = "c:\Inetpub\wwwroot\jobboard\resumes"
directoryToCheck = "c:\Inetpub\wwwroot\GTP\jobboard\upload"
' *************************************************************************************
%>
<%
function CheckIfDirectoryExists(directoryToCheck)
'Sidney Wiredu 01/09/2007
'preconditions: directoryToCheck must be parsible as a windows 9x directory location
'precondition: current os has Scripting.FileSystemObject COM Object and the current user who is running this function has permissions to instantiate an object of this class.
'Post-Conditions refer to "directory" or "folder" which is the hypothetical directory pointed to when directoryToCheck is interpreted as a Win 9x directory.
'Post-Condition: If directory does not exist, then the function will return a message stating that the folder does not exist.
'Postcondition: Elseif the directory exists, and the current user does not have write permissions to the directory, then the function will return a message stating that the folder does not have write permissions.
''
'Postcondition: Elseif the directory exists and the current user has write permissions to the folder but the current user does not have delete permissions to the folder, then the function will return a message stating that the user does not have delete permissions, but does have write permissions.
'Postcondition: Elseif the directory exists and the current user has write and delete permissions to the folder, but the COM object ADODB.Stream is not instantiatable for the current user, then the function will return a message stating that the ADODB.Stream object is not available.
'Postcondition: Elseif the directory exists and the current user has write and delete permissions to the folder, and the COM object ADODB.Stream is instantiatable for the current user, then the function will return an empty string.
'happy(myshoe)
'happy("myshoe")
'len("") will return 0
Dim fso, fileName, testFile, streamTest
CheckIfDirectoryExists = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(directoryToCheck) then
CheckIfDirectoryExists = "Folder " & directoryToCheck & " does not exist. "
exit function
end if
fileName = directoryToCheck & "\test.doc"
on error resume next
Set testFile = fso.CreateTextFile(fileName, true)
'If Err.Number<>0 then
' CheckIfDirectoryExists = "Folder " & directoryToCheck & " does not have write permissions. "
' exit function
' end if
Err.Clear
testFile.Close
fso.DeleteFile(fileName)
If Err.Number<>0 then
CheckIfDirectoryExists = "Folder " & directoryToCheck & " does not have delete permissions, although it does have write permissions. Change the permissions for IUSR_computername on this folder."
exit function
end if
Err.Clear
Set streamTest = Server.CreateObject("ADODB.Stream")
If Err.Number<>0 then
CheckIfDirectoryExists = "The ADODB object Stream is not available in your server. Check the Requirements page for information about upgrading your ADODB libraries."
exit function
end if
Set streamTest = Nothing
end function
function SaveFiles(directoryToCheck)
'This function saves the retrieved resume document to the folder.
'Precondition: A resume has been uploaded by the current user via the TheResume field.
'Precondition: Class FreeASPUpload is defined. How(?) It is defined within the ASP page.
'Precondition: When CheckIfDirectoryExists (directoryToCheck) is called, an empty string is returned
'check to see if the function executes off of server to upload the file to the folder
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
'' Set Upload = New Catastinasdoigasdgasloginadgadgfdapogmdspgoimsdfpgoimsdfgpoim
dim strRet
strRet=Upload.Save(directoryToCheck)
' If something fails inside the script, but the exception is handled
If Err.Number<>0 then Exit function
SaveFiles = ""
ks = Upload.UploadedFiles.keys
'will only be one file
if (UBound(ks) <> -1) then
SaveFiles = "File uploaded: "
for each fileKey in Upload.UploadedFiles.keys
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " "
next
else
SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
end if
' Sending an email to the user to be
Dim objConfig ' As CDO.Configuration
Dim objMessage', objMessage1 ' As CDO.Message
Dim Fields ' As ADODB.Fields
Const cdoSendUsingMethod = _
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = _
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = _
"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = _
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = _
"http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = _
"http://schemas.microsoft.com/cdo/configuration/sendpassword"
' Handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
' Set config fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail.globaltechpro.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "GTPPurchase"
.Item(cdoSendPassword) = "Purchase4us"
.Update
End With
'email content with proper fields indicated
mailBody = mailBody & "A New Resume has just been submitted:" & TheResume & vbCrLf & vbCrLf
'Dim objMessage
'--sending email to Global TechPro with Resume
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = "hire@globaltechpro.com"
.From = "info@globaltechpro.com"
.Subject = "Notification of Submitted Resume"
.TextBody = mailBody
''Set attachment file name here.
dim attachmentFileName
'Attached file with directory string and name of file
'attachmentFileName = directoryToCheck & "/" & localFileName
attachmentFileName=strRet
''end setting attachment file name here.
.AddAttachment attachmentFileName
.Send
End With
Set objMessage = Nothing
' Setting the objMessage to nothing
'Set objMessage1 = Nothing
Set objConfig = Nothing
Set Fields = Nothing
'.Send
'End With
end function
%>
Upload your resume for a career opportunity
at Global TechPro
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
'diagnostics = CheckIfDirectoryExists(directoryToCheck)
if diagnostics<>"" then
response.write "
"
response.write diagnostics
response.write "
After you correct this problem, reload the page."
response.write "
"
else
response.write "
"
'OutputForm()
response.write "
"
end if
else
response.write "
"
'OutputForm()
response.write SaveFiles(directoryToCheck)
response.write " Thank you for your submission. Your resume has been sent succesfully."
end if
%>