View Single Post

  #8 (permalink)  
Old 09-07-2004
Michael Fesser
 
Posts: n/a
Default Re: newbie needs help with checking for posted data

.oO(Miffed)

>"Michael Fesser" <netizen@gmx.net> wrote
>>
>> >$_POST["guess"] = (int) $_POST["guess"];

>>
>> There's no element 'guess' in the $_POST array when the script runs for
>> the first time, which causes a notice.

>
>I didn't notice an, er, notice, but I see your point anyway.


Set error_reporting to E_ALL in your php.ini to see all warnings and
notices. Good code should be free of such things, so E_ALL is a must on
a development system.

>While I'm here, can you or someone else please tell me why this won't work:
>
>[...]
>if ( isset( $_POST["fupload"] ) ) {
>// code not shown as it never executes anyway.
>}
>else // added by me to confirm test failed
> print ("not set<BR>");
>?>
>[...]
> <input type="file" name="fupload"><br>
>[...]
>
>As you'll see, this is a simple form to upload a file. Whether I send a
>file or not, the test for 'fupload' fails.


Yep, because it's not stored in the $_POST array, but in $_FILES
instead. Do a

print '<pre>';
print_r($_FILES);
print '</pre>';

at the beginning of the script, then call it in the browser and upload
something.

Chapter 34. Handling file uploads
http://www.php.net/manual/en/features.file-upload.php

HTH
Micha
Reply With Quote