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 8791725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:52:57+00:00 2026-06-13T22:52:57+00:00

My first post so be gentle! I’ve tried searching for this and there are

  • 0

My first post so be gentle! I’ve tried searching for this and there are many similar posts, but I can’t seem to find anything exactly like my problem and I have been at this for hours! :-/

I’m building a system in PHP (5.3) and MySQL and part of the functionality is that a user is required to upload some files based on some previous selections. An example form is as follows:

<form action="" method="post" enctype="multipart/form-data" id="uploadFiles">
<p>
<label for="file1">Upload file 1:</label>
<input type="file" name="file1" id="image">
</p>
<p>
<label for="file2">Upload file 2:</label>
<input type="file" name="file2" id="image2">
</p>
<p>
<input type="submit" name="upload" id="upload" value="Upload">
</p>
</form>

In this instance the user is required to upload two different documents. This all works for me and I can save the 2 files to the server and then insert 2 records to a table in the database with the file name, file type (pdf, jpg) and user id etc by looping through “$_FILES” in my Upload class.

What I am trying to do however is somehow add the name attribute <input name="foo"> to the inserted row so that “File 1” would have “file1” in a column called document_type and “File 2” would have “file2”. That way I can do a basic check in MySQL to see if the user has uploaded the appropriate files.

To cut to the chase, is there a way to assign or associate the INPUT “name” attribute to each file in $_FILES in my Upload class so that when when I loop through $_FILES, there is a unique document_type?

Please let me know if you require further information regarding my setup.

  • 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-06-13T22:52:58+00:00Added an answer on June 13, 2026 at 10:52 pm
    foreach ($_FILES as $inputName => $uploadedFile) {
        echo $inputName, ':', PHP_EOL;
        print_r($uploadedFile);
    }
    

    Output

    file1:
    Array (
        'name' => ...
        'tmp_name' => ...
        ...
    )
    file2:
    Array (
        'name' => ...
        'tmp_name' => ...
        ...
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First post here, I have tried searching but couldn't find what I'm looking for
first post here, I come in peace :) I've searched but can't quite find
This is my first post, so please be gentle. I've been playing around with
This is my first post on this forum (so please be gentle ) I'm
this if my first post so please be gentle. I have an iOS 5
This is my first post here - so be gentle :-) I want to
this is my first post, so be gentle :) I am brand new to
this is my first post, so be gentle. ;) PROBLEM: I would like to
This is my first post on StackOverflow, so please be gentle... I have some
This is my first post on SO, so be gentle. I'm not even sure

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.