Link to home
Start Free TrialLog in
Avatar of rcmb
rcmb

asked on

Assign NTFS permission information to file upload process

I am uploading a file via a website to a webserver. I do not want to use anonymous user to upload the file. How can I assign NTFS permissions to the file upload process so they can write the file to the folder. Here is the code I am using:

<%@ Language=VBScript %>
<%
option explicit
Response.Expires = -1
%>
<!-- #include file="upload.asp" -->
<%
      Dim uploadsDirVar, savedDirVar, copyFile, saveFile
      Dim fs,f
      uploadsDirVar = Server.MapPath("/Files/")
      savedDirVar = Server.MapPath("/ViewFiles/")

function SaveFiles
    Dim Upload, fileName, fileSize, ks, i, fileKey

      Session("filename") = ""
    Set Upload = New ASPUpload
    Upload.Save(uploadsDirVar)

    ks = Upload.UploadedFiles.keys
    if (UBound(ks) <> -1) then
        for each fileKey in Upload.UploadedFiles.keys
            Session("filename") = Upload.UploadedFiles(fileKey).FileName
                  If LEN(Session("Filename")) > 1 Then
                        copyFile = uploadsDirVar & "\" & Session("FileName")
                        saveFile = savedDirVar & "\" & Session("FileName")
                        response.write copyFile & "----" & saveFile & "<br>"
                        Set fs=Server.CreateObject("Scripting.FileSystemObject")
                        Set f=fs.GetFile(copyFile)
                        f.Copy saveFile,true
                        f.Delete
                        set f=nothing
                        set fs=nothing
                  End if
        next
    else
        SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
    end if

end function

      SaveFiles()
      
response.redirect ("statlink_add.asp")
%>
ASKER CERTIFIED SOLUTION
Avatar of Emad Gawai
Emad Gawai
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial