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

  • Home
  • SEARCH
  • 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 6960765
In Process

The Archive Base Latest Questions

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

I have ZERO experience coding uploading files through browser, so this part is all

  • 0

I have ZERO experience coding uploading files through browser, so this part is all very new to me.

I need to give users (in fact they will be only one or two authorized users) a way to upload multiple text files (think 50-200 files) directly into a MYSQL database.

I don’t want to give them FTP access, but am OK allowing them to enter files into the database.

I can figure out how to get the data from a PHP array into the MYSQL database.

What I can’t figure out is how to get the contents of multiple files into the PHP array(s).

Please help out with the code.

  • 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-27T15:26:37+00:00Added an answer on May 27, 2026 at 3:26 pm

    This example should help you understand the basic idea

    <?php
    $fileContents = Array();
    
    if(count($_FILES) != 0){
        foreach($_FILES as $file){
            $fp = fopen($file["tmp_name"], "r");
            array_push($fileContents, fread($fp, $file["size"]));
            fclose($fp);
        }
    
        //$fileContents now holds all of the text of every file uploaded
    }
    ?> 
    
    
    <html>
    <head>
    </head>
    <body>
        <form action="test.php" method="post" enctype="multipart/form-data">
        <input type="file" name="file1" id="file" />
        <input type="file" name="file2" id="file" />
        <input type="submit" name="submit" value="Submit" />
        </form>
    </body>
    </html>
    

    It first checks that there has been files posted to itself.
    If there is files, it loops through each and opens them while they are in their temporary file state.
    After that it reads all of the contents at once (be careful with this) using the size attribute that sent with it.
    At the same time, it is pushing the contents into the array called $fileContents.
    So $fileContents[0] holds the first text file and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have zero experience with COM. I actually never thought, I'll need to do
I have very little experience building software for Windows, and zero experience using the
this might be a simple question, but as I have zero experience in C++
I have zero experience with manipulating image files of any sort with code, so
Caveat: I have zero experience with MySQL. I've been given a series of files
I have zero experience writing applications with Swing, but I have one application with
I have zero idea as to why I'm getting this error.
I know zero javascript, and have one simple task: Find all text in the
I have zero experience with multiple displays & cocoa . Feel free to share
I have zero experience with Backbone.js currently, and before I start having a good

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.