0

I'm trying to create an upload script on a Win 2012 Server running IIS 8 and PHP 5.6. We can't get the PHP error logs running which is a big downer because it's hampering our ability to troubleshoot, so I figured I ask if anyone that has experience with PHP on a Windows server that might be able to help out.

I'm no fan of running PHP on IIS, but I have no choice in this case so please no flames there. We developed on a LAMP stack because we didn't have a WIMP stack available, when we tried to migrate we had much success but the upload script failed so I'm going to post the pertinent parts here and if anyone can lend a hand that would be awesome.

If I'm an idiot, moron, etc. I apologize.

	 // File Variables
	$_FILES["image"]["name"] = date("Y-m-d-H-i-s").
	'.png';
	$filename = $_FILES["image"]["name"];

	 //Path Variables
	$target_dir = "../uploads/";
	$target_path = $target_dir.$_FILES["image"]["name"];


	 // Upload
	if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
	  $actual_link = "http://".$_SERVER[HTTP_HOST].
	  "/uploads/".$filename;
	  $myMessage. = '<br/><img src="'.$actual_link.
	  '" width="300" height="224" /><br/>';
	}

I appreciate any assistance or guidance. Thanks!

1 Answer 1

2

First of all make sure that in php.ini safe_mode = Off and set display_errors or add following lines at the start of your code

<?php
ini_set("display_errors", 1);
ini_set('error_reporting', E_ALL);
?>

I had same problem with Windows Server 2012 R2 and IIS 8.5 with PHP Version 5.6

I tried everything that I could find on Internet but I was helpless. I was trying to assing permission of user "IIS_IUSRS" to "C:\Wdinwos\Temp" folder which is configured in php.ini as upload_tmp_dir and the folder where I was uploading the files/images. It was useless

Then I find out in my IIS Authentication -> Anonymous Authentication There is "IUSR". Then I added this user to "C:\Windows\Temp" and the folder where I was uploading files/images and it worked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.