Page 1 of 2

PHP on Windows File upload Problem

Posted: Thu Oct 05, 2006 10:16 am
by biznickman
I have the following code on my page:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<?php
print_r( $_FILES );
print_r( $_POST );
?>
</head>

<body>

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
</body>
</html>
If I post a file then the print_r($_FILES) and print_r($_POST) returns empty ... but if I don't post a file, I get back:
Array
(
[userfile] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)

)
Array
(
[MAX_FILE_SIZE] => 30000
)

Is there some configuration setting that I am missing? Please help!

Posted: Thu Oct 05, 2006 10:21 am
by volka
why are you printing the data as part of the <head> element?

Part o head

Posted: Thu Oct 05, 2006 10:23 am
by biznickman
Ok ... I've removed it from the head and put it above everything. No matter where I put it I recieve the same result.

Posted: Thu Oct 05, 2006 10:29 am
by volka
Can't tell you why
If I post a file then the print_r($_FILES) and print_r($_POST) returns empty
but
but if I don't post a file, I get back:
Array
(
[userfile] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
is correct
http://www.php.net/manual/en/features.file-upload.errors.php wrote:UPLOAD_ERR_NO_FILE

Value: 4; No file was uploaded.

Posted: Thu Oct 05, 2006 10:39 am
by biznickman
The second part is correct. But the first part isn't. If I attach a file, print_r($_FILES) returns:

Array
(
)

Instead it should show the information regarding the file that I'm uploading.

Posted: Thu Oct 05, 2006 11:32 am
by volka
Is this your own, private webserver installation?

Private Webserver?

Posted: Thu Oct 05, 2006 12:37 pm
by biznickman
Yeah it is. I have apache running on Windows XP.

Posted: Thu Oct 05, 2006 12:53 pm
by volka
So it doesn't do any harm if you remove that installation and try http://www.apachefriends.org/en/xampp.html ?

XAMPP installation

Posted: Thu Oct 05, 2006 1:13 pm
by biznickman
The only problem with installing XAMPP is that it is not secure, it is meant for "development environments". I will be transferring this over to a windows server and it would be useful to test in an identical environment. Any other suggestions?

Posted: Thu Oct 05, 2006 1:14 pm
by volka
biznickman wrote:The only problem with installing XAMPP is that it is not secure, it is meant for "development environments".
What did you install?

Installation

Posted: Thu Oct 05, 2006 1:37 pm
by biznickman
I installed

Apache,

MySQL,

PHP 5.1.5

Posted: Thu Oct 05, 2006 1:46 pm
by volka
And that is in what way more secure than xampp (1.5.4: Apache 2.2.3, MySQL 5.0.24a, PHP 5.1.6)?
(only testing wether "The only problem with installing XAMPP is that it is not secure" is just a phrase or there's something more to it ;))

Posted: Thu Oct 05, 2006 2:09 pm
by biznickman
I was just quoting their website. According to their website:
XAMPP is configured is to be as open as possible and to allow the web developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

Here a list of missing security in XAMPP:

* The MySQL administrator (root) has no password.
* The MySQL daemon is accessible via network.
* PhpMyAdmin is accessible via network.
* Examples are accessible via network.
* The user of Mercury and FileZilla are known.

Posted: Thu Oct 05, 2006 2:15 pm
by volka
And in what why does this affect your own project?
(i.e. I don't see why you can't test it right now with xampp)

Posted: Thu Oct 05, 2006 2:19 pm
by biznickman
I was just accepting what they said ... Can I install XAMPP with Apache, MySQL, and PHP already installed on my system?