Permission Denied in move_uploaded_file to another server in IIS

I struggled for a month to defeat this problem. I have a PHP web application running on IIS that allows a user to download a file from a simple html form. The downloaded file is then moved to a folder on another server. This works correctly on Apache, but fails on IIS with an error:

function ['move_uploaded_file'] could not open the stream: Permission denied in ...

I checked all permissions on directories a million times. If I run a simple PHP script through the command line to copy the file from the server to a folder on another server, it works correctly, so I suspect that the problem is related to IIS.

if (move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], "\\ 000.00.0.00 \ tia \ web \ upload \". $ _ FILES ["file"] ["name"])) {

+3
source share
2 answers

From what I see in your comment, you are using a network prefix \\as the target for your operation move_uploaded_file().

I put a beer so that PHP does not have access to this resource. Remember that PHP works with IIS permissions!

Try to save the local, globally accessible path first. If this works, you know that you need to fix the permissions.

+1
source

This has already been described here . Denoting the reason here:

, \server2\files. (, ), IUSR, , , php ( IIS). , , "unc", "\ server\share\folder\file.ext", , IUSR //

+1

Source: https://habr.com/ru/post/1785421/


All Articles