0

Try to upload a file to a web api and save it, When run the project locally with IIS it succeed to save the file with Chrome And IE11.
When i deploy the Project to the Test Env when try to save: With Chrome i get 'Acces is denied' With IE it's working.
How to make it work with Chrome as well?

Client Code:

            var data = new FormData();

            var files = $("#fileUpload").get(0).files;

            // Add the uploaded image content to the form data collection
            if (files.length > 0) {
                data.append("UploadedImage", files[0]);
            }

            // Make Ajax request with the contentType = false, and procesDate = false
            $.ajax({
                type: "POST",
                url: uriUser + "/UploadFile",
                contentType: false,
                processData: false,
                data: data,
                success: function (data) {
                try {
                    showMsg(MessageType.Info, data);
                    closeWin();
                }
                catch (e) {
                    if (e.message == "") {
                        showMsg(MessageType.Error, msg_error);
                    }
                }
            },
            error: function (response) {

                console.error('DeleteRole failed :' + response);
            }
            });

Server Code:

 var httpPostedFile = HttpContext.Current.Request.Files["UploadedImage"];

 // Some manipulation to get the FileName and the Path...
 httpPostedFile.SaveAs(fileSavePath);
user384496
  • 180
  • 1
  • 2
  • 16
  • Application pool that is running the app will need to have the write access. – Hozikimaru Aug 01 '18 at 14:15
  • The IT admin told me that the Chrome doesn't pass correctly the credentials. he could change the pool but he won't do that. He says it's not suppose to work that way. Do i have some alternative beside explicit grunt a permission to some group in the pool? Maybe changing the code on the client/server? – user384496 Aug 02 '18 at 04:52
  • I am not sure what credentials that would be Chrome would be passing. If he is expecting the Chrome to pass over some AD credentials for actually writing the file, that wont happen magically. The app pool context is the one that actually writes the file which means that it will inherit whatever app pool's permission is. Check out : https://stackoverflow.com/questions/14653722/how-do-i-give-asp-net-permission-to-write-to-a-folder-in-windows-7 – Hozikimaru Aug 02 '18 at 12:47
  • Check with the admin again, He did give a a write permission to a group that i member of and still it won't work with Chrome. only in IE. – user384496 Aug 07 '18 at 11:21

0 Answers0