Page 1 of 1

forms with upload files and normal input tags

Posted: Thu Jul 11, 2002 6:16 am
by e98cuenc
Hi!

I have to do a form that should be used to post some information and (optionally) to upload some files.

When I put the encoding of the form to multipart/form-data I'm able to read the updated files, but I can not access anymore the other input fields of the form as global variables. For example, if the form is:

<form enctype="multipart/form-data" action="send.php" method="post">
<input type="text" name="build" size="20">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="file" name="att" size="19">
<input class="clsButton" type="submit" value="Submit" name="submit">
</form>

I'm not able to read the value of "build".

Do you know how can I read the "build" value without changing the enctype (need to upload files)?

I've been searching for a while, and the only thing that I've found is a comment in the php manual page, saying that when you use multipart/form-data, you should use $HTTP_RAW_POST_DATA to get the value of the variables of your form, but I don't know hot to parse $HTTP_RAW_POST_DATA to get the variables of the form.

Thank you in advance!

Cheers,

Posted: Thu Jul 11, 2002 8:47 am
by llimllib
the value "build" is located in $_POST['build'], at least in the test i just did on my comp (php 4.2.1). I believe, though I'm not sure, that only the uploaded file is stored in the $HTTP_RAW_POST_DATA variable.

Posted: Thu Jul 11, 2002 9:01 am
by e98cuenc
For the record, $build was not available anywhere until I changed in php.ini from the default (using php 4.1.2 in a redhat linux 7.3)

file_uploads = Off

to

file_uploads = On

(yes, I know that it looks stupid... but afaik this option is not mentioned in the upload part of the php manual, so it took me a while to find the problem...)

Now I've got all the form variables and my files are uploaded correctly... except when I try from a computer != localhost using IE... I still don't know why it only works from localhost, but I've not yet searched hard enough for a solution.

Thank you for your help!

Cheers,

Posted: Thu Jul 11, 2002 9:36 am
by llimllib
good call, file_uploads was already on for me, so I forgot about that. good luck getting it to work.