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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:28:38+00:00 2026-06-14T10:28:38+00:00

First of all sorry for the confusing thread title. I couldn’t come up with

  • 0

First of all sorry for the confusing thread title. I couldn’t come up with a better one.

I use associative arrays for names of form elements so that it makes it easier to run the insert query while processing the form. Something like:

<input type="text" name="v[fname]" />
<select name="v[location]">
    <option val="1">ABC</option>
    <option val="2">DEF</option>
</select>
<textarea name="v[comments]"></textarea>

So that I could simply do:

$v = $_POST[v];

// single line execution for insert    
"INSERT INTO ".$tableName." ( ". implode( ',', array_keys( $v) ) .") VALUES( '". implode( "','", $v ) . "')"

Now sometimes, the forms that I deal with are bound to contain <input type="file" /> elements. I was wondering if there is a way to :

  • Detect if a file is being uploaded
  • If yes, store the path of the file inside $v so that I can use that
    array in the same manner as specified above

So, in a nutshell, I’m looking for something like this:

if(isset($_POST['add'])) // when submit button is clicked
{
   $v = $_POST['v']; // store other element values
   if(condition to check if a file is being uploaded through the form)
   {
      $path = 'get the path where it will be uploaded'; //This part I can handle. What I'm having trouble with is finding a way to get into **this** if condition
      $v['path'] = $path; // store the path inside $v
   }

   //proceed with the insert statement as usual

}
  • 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-14T10:28:40+00:00Added an answer on June 14, 2026 at 10:28 am

    Can you check the contents of $_FILES?

    if(!empty($_FILES)) {
      //do what you need to do
    }
    

    doc: http://www.php.net/manual/en/reserved.variables.files.php

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

Sidebar

Related Questions

first of all, sorry if the title is a bit confusing. i'm planning to
the title is confusing sorry, if you can think of a better one, please
First of all sorry for the name of the title, but i dont know
first of all sorry for the title. I know this is not so clear
First of all sorry that I could not think of a more descriptive title.
First of all sorry for my English. I would like to use a backtracking
First of all Sorry if my question title sounds stupid.... I have the following
first of all, sorry for the non descriptive title, I'm just too rushed so
First of all: Sorry for my bad English! I know the title isn't the
First of all I don't know how to phrase the question title, sorry if

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.