-1

i have an extremely large form that is being submitted to an 'update' page which runs some SQL queries and updates the fields and then redirects back to the original page. everything has been working properly. I'm using $_POST to send my variables to the update page.

i recently needed to add a <input type='file' /> field to the page. Whenever the user selects a file, the form breaks, and nothing is getting submitted to the next page.

I tried echoing my $_POST variables on the update page. They come through perfectly as long as the file field isn't set. If I choose a file, then none of the variables come though.

i'm really stumped as to why this is happening. does anyone have any ideas why. here is an excerpt.

An excerpt of the huge form:

<form enctype="multipart/form-data" method="post"  action="editConfirm.php">
      .
      .
     <input type="file" name="new_file" id="new_file"  />                                           
     <input type='field' width='25px' name='fakeInput' id='fakeInput' value='' />
     <input type="hidden" name="compressed_file_id" id="compressed_file_id"   value='<? echo $compressedID; ?>' />

And the confirmation page:

echo "New File = ".$_POST['new_file'];
echo "<br />Master Title = ".$_POST['masterTitle'];
echo "<br />Compressed File ID = ".$_POST['compressed_file_id'];

So those all echo properly as long as New File isn't set. If I select a file and submit the form, they all break and nothing comes through.

patricko
  • 831
  • 4
  • 16
  • 34
  • You might get stuck because the servers max post size or similar gets exceeded. Check this for a start: http://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size Also if you can see Apaches/PHP error log if anything there – jtheman Nov 07 '12 at 21:50
  • could that be the problem? i won't have access to my php.ini until tomorrow... what is the max size that $post can send? – patricko Nov 07 '12 at 21:51
  • 1
    you can check in `phpinfo();` although I don't think you can access `$_POST['new_file']`. You should use [$_FILES](http://php.net/manual/en/reserved.variables.files.php). – rationalboss Nov 07 '12 at 21:53
  • different for different server setups. But you can try to set it with .htaccess (see in above link) – jtheman Nov 07 '12 at 21:53
  • The new one people often overlook is [max_input_vars](http://www.php.net/manual/en/info.configuration.php#ini.max-input-vars) which came along well after post_max_size and upload_max_filesize. Note it's changable PHP_INI_PERDIR. – ficuscr Nov 07 '12 at 21:55
  • ok so I tried `print_r($_FILES)` and nothing is coming through... – patricko Nov 07 '12 at 21:58

1 Answers1

2

You wil not get uploaded file array as $_POST. You have to use $_FILES["new_file"] to get file properties array

Reference http://php.net/manual/en/reserved.variables.files.php

admoghal
  • 1,498
  • 1
  • 10
  • 5