Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6968361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:26:30+00:00 2026-05-27T16:26:30+00:00

For some reason i have to put all input field into array.Because the input

  • 0

For some reason i have to put all input field into array.Because the input are dynamically added up to user.

When user click on add button ,will generated the following for upload image

<input type="file" name="product['+n+'][gthumbnail][]"  />

But i have no idea how to loop the available array(filled).I don’t even get to count the array size.And these are my working code.Hope every expert out there can point out the mistake I did

//loop for image file upload
foreach($product as $productcount){

....
....
....

    //this is what i have now ,and it is not working,error saying the gthumbnail is undefined
    for($i=0;$i<sizeof($_FILES['gthumbnail']);$i++){

        $m=uploadFile($_FILES['gthumbnail'][$i]);

    }


}//End of product loop

print_r($FILES)

Array ( 
[product] => Array ( [name] => Array ( [1] => Array ( [thumbnail] => [gthumbnail] => Array ( [0] => [1] => [2] => ) [gphoto] => Array ( [0] => [1] => [2] => ) ) ) [type] => Array ( [1] => Array ( [thumbnail] => [gthumbnail] => Array ( [0] => [1] => [2] => ) [gphoto] => Array ( [0] => [1] => [2] => ) ) ) [tmp_name] => Array ( [1] => Array ( [thumbnail] => [gthumbnail] => Array ( [0] => [1] => [2] => ) [gphoto] => Array ( [0] => [1] => [2] => ) ) ) [error] => Array ( [1] => Array ( [thumbnail] => 4 [gthumbnail] => Array ( [0] => 4 [1] => 4 [2] => 4 ) [gphoto] => Array ( [0] => 4 [1] => 4 [2] => 4 ) ) ) [size] => Array ( [1] => Array ( [thumbnail] => 0 [gthumbnail] => Array ( [0] => 0 [1] => 0 [2] => 0 ) [gphoto] => Array ( [0] => 0 [1] => 0 [2] => 0 ) ) ) ) )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:26:30+00:00Added an answer on May 27, 2026 at 4:26 pm

    why don;t you try with a single dimension array instead of name="product['+n+'][gthumbnail][]". It looks like very complicated one.

    may be the following will make your work easier,

     <form action="file-upload.php" method="post" enctype="multipart/form-data">
      Send these files:<br />
      <input name="userfile[]" type="file" /><br />
      <input name="userfile[]" type="file" /><br />
      <input type="submit" value="Send files" />
    </form>
    

    When the above form is submitted, the arrays $_FILES['userfile'], $_FILES['userfile']['name'], and $_FILES['userfile']['size'] will be initialized.

    When register_globals is on, globals for uploaded files are also initialized. Each of these will be a numerically indexed array of the appropriate values for the submitted files.

    For instance, assume that the filenames /home/test/review.html and /home/test/xwp.out are submitted. In this case, $_FILES[‘userfile’][‘name’][0] would contain the value review.html, and $_FILES[‘userfile’][‘name’][1] would contain the value xwp.out. Similarly, $_FILES[‘userfile’][‘size’][0] would contain review.html’s file size, and so forth.

    $_FILES['userfile']['name'][0], $_FILES['userfile']['tmp_name'][0], $_FILES['userfile']['size'][0], and $_FILES['userfile']['type'][0] are also set.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller user with a method login For some reason, when I
For some reason I have always assumed that most of the time a variable
For some reason I have a very ugly orange part of a border around
I use prototype since a long time, but for some reason I have to
For some reason the Windows command prompt is special in that you have to
For some reason, we have a script that creates batch files to XCOPY our
For some reason, my visual studio 2008 installation doesn't have the Create Test Project
For some reason, after installing the iPhone OS 3.0 SDK, I have no option
I have a crash that is happening deep within UIKit for some reason; an
I have just tried using the NSArchiver but for some reason I am getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.