25. 03.

Recently I moved all my sites over to a Windows dedicated server. They had previously been on two different machines - one Windows and One Linux.

I discovered today that scripts that used the form enctype=”multipart/form-data” to upload images to the server no longer worked while running PHP under IIS (as an ISAPI).

Hopefully my friend Google will have brought you here for a possible answer to your problem:

For reason unknown to me your code MUST use the $_FILES method of accessing the file rather than the named form.

The following method will work for PHP on Windows:

<?php
if ( !empty($_FILES['file']['tmp_name']) ) {
move_uploaded_file($_FILES['file']['tmp_name'], ‘./’ . $_FILES['file']['name']);
header(’Location: http://www.mywebsite.com/dump/’);
exit;
}
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html>
<head>
<title>Dump Upload</title>
</head>
<body>
<h1>Upload a File</h1>
<form action=”upload.php” enctype=”multipart/form-data” method=”post”>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”1000000000″ />
Select the File:<br /><input type=”file” name=”file” /><br />
<input type=”submit” value=”Upload” />
</form>
</body>

Thanks to the folks at Stack Overflow for the code

Do check your file system permissions as well, but referencing $file_name does not seem to work for PHP on Windows.