<!--#include file="function.asp"-->
<%
'  Variables
'  *********
   Dim mySmartUpload
   Dim serverPath

   if Request.ServerVariables("SERVER_NAME") <> "sql-server" then
       serverPath = "c:\inetpub\wwwroot\contacts\"
   else
      serverPath = "c:\inetpub\wwwroot\bmsa\contacts\"  
   end if


'  Object creation
'  ***************
   
   UID = getUserID(request.cookies("ckyUserID"))
   'response.write(UID )
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")  
   mySmartUpload.CodePage = "utf-8"
   'If mySmartUpload Is Nothing then 
   '  response.write("dead")
   'End If
   mySmartUpload.Upload
   'FORM ACTIONS
   if mySmartUpload.Form("btnSubmit").values = "Add" and mySmartUpload.files("FILE1").Filename <> "" then
   
      '  Upload
      '  ******
      ' mySmartUpload.files("FILE1").SaveAs "tmp_upload/" & UID & "_" & mySmartUpload.files("FILE1").Filename
      mySmartUpload.files("FILE1").SaveAs "tmp_upload/" & UID & "_" & mySmartUpload.files("FILE1").Filename
    
   elseif mySmartUpload.form("btnDelete").values = "Remove" then
      Dim fso
      if mySmartUpload.form("fselect").values <> "" then
         Set fso = Server.CreateObject("Scripting.FileSystemObject")
         fso.DeleteFile(serverPath & "tmp_upload\" & mySmartUpload.form("fselect").values)
         response.write(mySmartUpload.form("fselect").values)
         set fso = nothing
      end if
   end if

   set mySmartUpload = nothing

   Response.Redirect ("fAttach.asp")
%>
