We help IT Professionals succeed at work.

New podcast episode! Our very own Community Manager, Rob Jurd, gives his insight on the value of an online community. Listen Now!

x

Assign NTFS permission information to file upload process

rcmb
rcmb asked
on
258 Views
Last Modified: 2008-01-09
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")
%>
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.