Link to home
Start Free TrialLog in
Avatar of lkrubner
lkrubnerFlag for United States of America

asked on

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

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.



Avatar of lkrubner
lkrubner
Flag of United States of America image

ASKER

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.

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
ASKER CERTIFIED SOLUTION
Avatar of raja_ind82
raja_ind82
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.