Uploading files doesn't work anymore

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

Post Reply
herman
Forum Newbie
Posts: 2
Joined: Mon Sep 16, 2002 3:24 pm

Uploading files doesn't work anymore

Post by herman »

Hi,

When I use the .php3 extension I don't have any problems uploading files using the following script:

<form name="Upload" ENCTYPE="multipart/form-data" action="test.php3" method="post">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="102400">
<INPUT TYPE="hidden" name="action" value="upload">
Upload File:
<INPUT NAME="uploadFile" TYPE="file">
<input type="submit" Value="Upload">
</form>

But when I use .php all seems to go ok, but in fact the $uploadFile variable stays empty! (also $uploadFile_name, $uploadFile_size as well as $_POST['uploadFile'] , $_POST['uploadFile']['name'] etc.) Any explanation for this?

BTW:
It's not the common register_globals_form-bug posted several times already on this forum. Other variables go perfectly.
(for example: $_POST["MAX_FILE_SIZE"]=102400
and $_POST["action"]=upload )

All other scripts work perfectly in both .php and .php3 (as long as I don't use php 4 functionality). I want to upload files AND I want to use some functionality not available in PHP3.

my latest guess is that my PHP4.2-server doesn't allow me to upload files anymore. How do I check this? My phpinfo() says:
file_uploads no value

Who will come with the solution?
Thanks a lot,

Herman
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

What's the php code you're using? Can we have a look?
herman
Forum Newbie
Posts: 2
Joined: Mon Sep 16, 2002 3:24 pm

Post by herman »

Takuma,

What you mean by showing the php-code? the code is not the problem it's working fine, it's the variables that aren't passed which is the problem. Let me try to show you.

After I select a file using the form that I posted and having the following lines in my code:

Code: Select all

echo("uploadFile=$uploadFile<br>\n");
echo("uploadFile_size=$uploadFile_size<br>\n");
echo("uploadFile_type=$uploadFile_type<br>\n");
echo("uploadFile_name=$uploadFile_name<br>\n");

echo("POST uploadFile=" . $_POST&#1111;'uploadFile'] . "<br>\n");
echo("POST uploadFile&#1111;size]=" . $_POST&#1111;'uploadFile']&#1111;'size'] . "<br>\n");
echo("POST uploadFile&#1111;type]=" . $_POST&#1111;'uploadFile']&#1111;'type'] . "<br>\n");
echo("POST uploadFile&#1111;name]=" . $_POST&#1111;'uploadFile']&#1111;'name'] . "<br>\n");

echo("FILES uploadFile=" . $_FILES&#1111;'uploadFile'] . "<br>\n");
echo("FILES uploadFile&#1111;size]=" . $_FILES&#1111;'uploadFile']&#1111;'size'] . "<br>\n");
echo("FILES uploadFile&#1111;type]=" . $_FILES&#1111;'uploadFile']&#1111;'type'] . "<br>\n");
echo("FILES uploadFile&#1111;name]=" . $_FILES&#1111;'uploadFile']&#1111;'name'] . "<br>\n");
This is the output when I run test.php3:

uploadFile=./php8n9phI
uploadFile_size=1881
uploadFile_type=image/gif
uploadFile_name=file.gif
POST uploadFile[size]=
POST uploadFile[type]=
POST uploadFile[name]=
FILES uploadFile=
FILES uploadFile[size]=
FILES uploadFile[type]=
FILES uploadFile[name]=

And this when I use the exact same script as test.php:

uploadFile=
uploadFile_size=
uploadFile_type=
uploadFile_name=
POST uploadFile=
POST uploadFile[size]=
POST uploadFile[type]=
POST uploadFile[name]=
FILES uploadFile=
FILES uploadFile[size]=
FILES uploadFile[type]=
FILES uploadFile[name]=

You see the problem? Anyway, I prefer using phpinfo() to check these variables but for this forum I thought this is more clear.

So, you have any idea what might cause this behavior? I am stuck for some days already.

Thanks a lot,

Herman
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

it sounds like that might be the case, I do file uploads with my host and here is what my php info looks like:

Code: Select all

file_uploads    1     1
have you contacted your host?
mh
Forum Newbie
Posts: 4
Joined: Fri Jan 03, 2003 5:19 am
Contact:

err...

Post by mh »

Hi,
Help me understand this peculiar behaviour..
I tried the script u have posted saving it as 'uploadtest.php'. i have my register_globals set to on. when i ran the script, i got the following displayed:

uploadFile=C:\WINDOWS\TEMP\phpE0E5.TMP
uploadFile_size=49823
uploadFile_type=image/pjpeg
uploadFile_name=Flower1.jpg
POST uploadFile=
POST uploadFile[size]=
POST uploadFile[type]=
POST uploadFile[name]=
FILES uploadFile=Array
FILES uploadFile[size]=49823
FILES uploadFile[type]=image/pjpeg
FILES uploadFile[name]=Flower1.jpg

to check, i just turned my register_globals off n then ran the script. but i got absolutely no dispaly. the input form remained. i am a beginner n thus wold appreciate if u could explain the behaviour.

Thz

mh
Post Reply