Search code examples
phpfile-uploadwindows-server-2008

PHP File Uploading Issues


I'm trying to implement script that will allow a file to be uploaded, and then moved to a designated directory. This is running on a Windows server & IIS. I'm having 2 issues in doing so.

First, I get an error when trying to move the file.

Warning: move_uploaded_file(reports/ff.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\inetpub\wwwroot\betterinsight\betterinsight\upload_file.php on line 29

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\php1EAB.tmp' to 'reports/ff.jpg' in C:\inetpub\wwwroot\betterinsight\betterinsight\upload_file.php on line 29
Stored in: reports/ff.jpg

When searching, almost everything says it's a permission problem. I have added full rights (will pare down later) to the user: IIS_IUSRS. Even did it to the parent directory as one site recommended.

Second: As a possible solution to the above issue, I tried changing the directory in which files are saved. But the files are still uploaded into C:\windows\temp.
I've run phpinfo, and it says that uploads should be in (as defined by upload_tmp_dir):

Again, this is on a Windows Server 2008. Thanks.


Solution

  • OK, the answer was simple. I was adding permissions for user: IIS_USRS, when it should have been just user: USRS.