PHP on Windows File upload Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

PHP on Windows File upload Problem

Post 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!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

why are you printing the data as part of the <head> element?
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

Part o head

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Is this your own, private webserver installation?
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

Private Webserver?

Post by biznickman »

Yeah it is. I have apache running on Windows XP.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

So it doesn't do any harm if you remove that installation and try http://www.apachefriends.org/en/xampp.html ?
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

XAMPP installation

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

Installation

Post by biznickman »

I installed

Apache,

MySQL,

PHP 5.1.5
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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 ;))
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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)
biznickman
Forum Newbie
Posts: 13
Joined: Tue Aug 16, 2005 10:32 am

Post by biznickman »

I was just accepting what they said ... Can I install XAMPP with Apache, MySQL, and PHP already installed on my system?
Post Reply