We help IT Professionals succeed at work.

The file input in my form is not showing up when I submit the form

lkrubner
lkrubner asked
on
193 Views
Last Modified: 2012-05-05
I've this form on one of my pages. Note that the name for the "file" input is the same as any other:



<form method="post" action="profile.php?id=5&formName=my_story_edit.htm" enctype="multipart/form-data">
            
      <p>My story:<br />
            <textarea name="totalFormInputs[users][5][description]">I grew up in New Jersey.  </textarea></p>

      
      <p>Email address:<br />
             <input type="text" name="totalFormInputs[users][5][email_address]" value="lawrence@krubner.com" /></p>
                              
      <p>Zip code:<br />
            <input type="text" name="totalFormInputs[users][5][zip_code]" value="22902" /></p>
                              
      <p>Personal image:<br />
            <input type="file" name="totalFormInputs[users][5][upload_file]" /></p>

<input type="submit" value="Update" />

<input type="hidden" name="choiceMade[]" value="createRecordsForMultipleDatabaseTables" />

<input type="hidden" name="totalFormInputs[users][5][time]" value="1187380627" />

</form>




When this form submits, it triggers the function "createRecordsForMultipleDatabaseTables". At the top of that I get the variable $totalFormInputs. If I feed that to print_r(), I find that the "file" input has mysteriously disappeared:



Array
(
    [users] => Array
        (
            [5] => Array
                (
                    [description] => I grew up in New Jersey. I started drinking when I was 12. I stopped when I was 32.
                    [email_address] => lawrence@krubner.com
                    [zip_code] => 22902
                    [time] => 1187380627
                )

        )
)



Why is this happening? Where did it go?

I had this script working for a year. There have been some changes to the server, but none that I think would effect this.

Actually, this script is still working in most ways. The array tells the code to update record 5 in  the MySql table "users". That part works fine.

But where is the file input info?

I keep choosing different images, but nothing shows up. I've used both Macs, Windows and Ubuntu Linux to test this form.



Comment
Watch Question

Author

Commented:
You can see the form here:

http://www.bluewalldev.com/secondroad/profile.php?id=5&formName=my_story_edit.htm


I apologize the site is so rough. We are at an early point of construction.

Author

Commented:
It's bizzare. I'm getting the right results in $_FILES, but not in $_POST. If I do print_r($_FILES) I get this:

Array
(
    [totalFormInputs] => Array
        (
            [name] => Array
                (
                    [users] => Array
                        (
                            [5] => Array
                                (
                                    [upload_file] => car_derby.jpg
                                )

                        )

                )

            [type] => Array
                (
                    [users] => Array
                        (
                            [5] => Array
                                (
                                    [upload_file] => image/jpeg
                                )

                        )

                )

            [tmp_name] => Array
                (
                    [users] => Array
                        (
                            [5] => Array
                                (
                                    [upload_file] => /tmp/phpiBxJrN
                                )

                        )

                )

            [error] => Array
                (
                    [users] => Array
                        (
                            [5] => Array
                                (
                                    [upload_file] => 0
                                )

                        )

                )

            [size] => Array
                (
                    [users] => Array
                        (
                            [5] => Array
                                (
                                    [upload_file] => 32302
                                )

                        )

                )

        )

)


That looks right to me. Yet if I do print_r($_POST), then upload_file is mysteriously missing from totalFormInputs.

How is that possible?
Hi
i had look at your page. i am selecting one image and click update button. that display the uploaded file details at top.
Array ( [totalFormInputs] => Array ( [name] => Array ( [users] => Array ( [5] => Array ( [upload_file] => 3.jpg ) ) ) [type] => Array ( [users] => Array ( [5] => Array ( [upload_file] => image/pjpeg ) ) ) [tmp_name] => Array ( [users] => Array ( [5] => Array ( [upload_file] => /tmp/phpWIcM7x ) ) ) [error] => Array ( [users] => Array ( [5] => Array ( [upload_file] => 0 ) ) ) [size] => Array ( [users] => Array ( [5] => Array ( [upload_file] => 190390 ) ) ) ) ) Array ( [users] => Array ( [5] => Array ( [description] => I grew up in New Jersey. I started drinking when I was 12. I stopped when I was 32. [email_address] => lawrence@krubner.com [zip_code] => 22902 [time] => 1187380627 ) ) )

i hope you won't fill the filename/filepath to file control. instead of that you can show the current image just above the file control line. so the user can see the uploaded images and they can update the images in future.

Actually, what do you need from this? if you have any doubt in this, please explain little bit more.

Regards,
M.Raja
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Apparently in PHP 5 a file upload no longer shows up in $_POST. It only shows up in $_FILES. This change broke my code. My upload script has worked for years, under PHP 4, but it no longer works.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.