0

I have been working on a file management system where we can upload files from a web page and then search through a database to find said files. The issue I am currently running into is that when I upload the file via the website it does not give users permission to read/write, so when I try to download the file it gives me a server error. I have manually changed individual files to allow the correct user to read/write and then I can download the file just fine. I can not however do this for every single file because I will be having roughly 20 users uploading files every day, so I need them to be uploaded with these permissions by default.

Upload Code

<?php
if(isset($_POST['submit'])) {
    $file = $_FILES['file'];
    $fileName = $file['name'];
    $fileName = str_replace(" ","blankspace",$fileName);
    $fileName = str_replace("#","poundsymbol",$fileName);
    $fileName = str_replace("_","underscore",$fileName);
    $fileName = str_replace("-","dashsymbol",$fileName);
    if (!empty($fileName)) {
        $fileType = $file['type'];
        $fileTmpName = $file['tmp_name'];
        $fileSize = $file['size'];
        $fileError = $file['error'];
        $without_extension = substr($fileName, 0, strrpos($fileName, "."));

        $temp= explode('.',$fileName);
        $extension = end($temp);

        $fileDestination = 'C:\inetpub\wwwroot\documents\\'.$fileName;
        move_uploaded_file($fileTmpName,$fileDestination);
        $fileDestination2 = str_replace("\\", "/", $fileDestination);
        $fileDestination2 = str_replace(" ", "%20", $fileDestination2);
        
        echo $fileDestination;
        echo "<br>";
        echo $fileDestination2;
        echo "<br>";
        echo"DOCUMENT UPLOADED";
        #echo $_FILES['userfile']['error'];
    } else {
        echo"NO DOCUMENT";
    }
  
};
?>

Download Code

echo '<th><a href="'.$FileLocation.'" download="'.$NewDocName.'">Download</a></th>';

(I know the download code works because as stated previously if I manually change the file permission and then attempt to download it works just fine)

I need to have IIS_IUSRS to default have full control of the files. Currently IIS_IUSRS do not even show up in the Group/User section in the security tab. I have made sure IIS_IUSRS has full control permissions in the documents folder they are being uploaded to.

I have spent several hours researching this issue with a few of my colleges and we can not even find a starting point. I do not believe there are any other posts on stackoverflow that cover this issue, if there is I was unable to find it.

If anyone has any idea how to fix this issue, or even a place to start looking for a solution I would be immensely greatfuly

Default User Permissions Corrected User Permissions

ADyson
  • 51,527
  • 13
  • 48
  • 61

0 Answers0