Page 1 of 1

PHP 5/IIS 6/MySql 5 - File cannot be uploaded

Posted: Thu Nov 27, 2008 1:19 am
by khalidmehmoodawan
Hi guys :banghead:

well the emotion above can tell you how frustrated i am...

here is the issue:

I have a windows 2003 server with IIS 6, mysql 5 and php 5 installed and configured on it. Php websites are running fine on it with mysql database accepting transactions.

I have a webpage that uploads files to webserver and saves in webpage sub directory (./store/files/), their links and other information is stored to mysql server database.

remember that the file upload is successful on a WAMP server when i test the site locally.

But its not working on the IIS webserver.
php.ini file has max post data and max_file size variables configured as 20 MB

i have also allowed users to read, run scripts, write, browse the web directory in IIS configuration.

When i try to upload a file, File upload Successful msg is shown as per script, the record is saved in mysql database

BUT.....

The file is not there in the subdirectory (./store/files/)

Same code is running perfectly with wamp server (php, mysql, apache)

navigate to website/admin page to upload files

code with database table info is attached....

pleaseeeeeeeeeeeeeeee help :cry: Today is my deadline.

Re: PHP 5/IIS 6/MySql 5 - File cannot be uploaded

Posted: Thu Nov 27, 2008 2:12 am
by requinix
You... you put everything... available to download... :banghead:

You don't check if the move itself was successful (note how that word only has one 'l' in it).
Turn your error reporting up all the way, enable display_errors, and see what happens.

Code: Select all

// at top of the file
error_reporting(E_ALL);
ini_set("display_errors", 1);
Oh, and you should never connect to your database as root. Especially when root doesn't have a password. But it's okay, it's just a temporary thing... right?

Re: PHP 5/IIS 6/MySql 5 - File cannot be uploaded

Posted: Thu Nov 27, 2008 2:21 am
by khalidmehmoodawan
hmmm... well let me try this and get back to you here :-)

Thanks :|

Re: PHP 5/IIS 6/MySql 5 - File cannot be uploaded

Posted: Thu Nov 27, 2008 3:34 am
by khalidmehmoodawan
Warning: move_uploaded_file(Library/status.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\uploadtest\file.php on line 8

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\phpD.tmp' to 'Library/status.txt' in C:\Inetpub\wwwroot\uploadtest\file.php on line 8

---- tried this short code and it gave these warnings. it seems that i do not have permission over the temporary folder where files resides till shifted or completely uploaded.

any more help ?



<?PHP
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(isset($_POST["Submit"]))
{
$uploaddir = 'Library/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "File is valid, and was successfully uploaded.\n";
}
else
{
echo "Possible file upload attack!\n";
//echo $_FILES['userfile']['error'] . "\n";
//echo "\n". $_FILES["userfile"]["tmp_name"] . "\n";
//echo basename($_FILES['userfile']['name']) . "\n";
}
}
?>
<form action="file.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="userfile" type="file" id="userfile" />
<input type="submit" name="Submit" value="Submit" />
</form>

Re: PHP 5/IIS 6/MySql 5 - File cannot be uploaded

Posted: Thu Nov 27, 2008 8:12 am
by khalidmehmoodawan
The issue has been resolved. :D

Actually the IIS Guest user had no permissions to save temporary file to the temporary upload folder. When it was given rights, the files uploaded successfully.


1. Check what is the directory against upload_tmp_dir in php.ini
2. Check that the default Internet user , IUSR_***** has rights to save a file to this folder.

Your issue will be resolved. Now i can :lol: