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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:16:43+00:00 2026-05-31T11:16:43+00:00

Below I have included my code that uploads multiple images to a folder and

  • 0

Below I have included my code that uploads multiple images to a folder and the path to mysql. I am brand new so please excuse me for such a silly question but I can not figure where to start with sending this timestamp or $fileName value to mysql.

<?php
require_once('storescripts/connect.php');
mysql_select_db($database_phpimage,$phpimage);
$uploadDir = 'upload/';

if(isset($_POST['upload']))
{


foreach ($_FILES as $file)
{

    $fileName = $file['name'];
    $tmpName = $file['tmp_name'];
    $fileSize = $file['size'];
    $fileType = $file['type'];

    if ($fileName != ""){
        $filePath = $uploadDir;
        $fileName = str_replace(" ", "_", $fileName);

        //Split the name into the base name and extension
        $pathInfo = pathinfo($fileName);
        $fileName_base = $pathInfo['fileName'];
        $fileName_ext = $pathInfo['extension'];

        //now we re-assemble the file name, sticking the output of uniqid into it
        //and keep doing this in a loop until we generate a name that 
        //does not already exist (most likely we will get that first try)
        do {
           $fileName = $fileName_base . uniqid() . '.' . $fileName_ext;
        } while (file_exists($filePath.$fileName));

        $result = move_uploaded_file($tmpName, $filePath.$fileName);
    }


if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$fileinsert[]=$filePath;
}
    $cat=$_POST['cat'];//this is the category the product is stored in
    $about=$_POST['about'];//this is some general information about the item
    $price=$_POST['price'];//the price of the item
    $item=$_POST['item'];//the name of the item
    $name1=basename($_FILES['image01'][$fileName]);//the file name of the first actual jpg
    $name2=basename($_FILES['image02'][$fileName]);//the file name of the sencond actual jpg
    $name3=basename($_FILES['image03'][$fileName]);//the file name of the third actual jpg
    $name4=basename($_FILES['image04'][$fileName]);//the file name of the fourth actual jpg

$query = "INSERT INTO image (mid, cid, about, price, item, name1, name2, name3, name4) ".
"VALUES ('','$cat','$about','$price','$item','$name1','$name2','$name3','$name4')";

mysql_query($query) or die('Error, query failed : ' . mysql_error()); }


?>
  • 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-31T11:16:44+00:00Added an answer on May 31, 2026 at 11:16 am

    If I understand your question correctly, you need to change:

    $fileinsert[]=$filePath;
    

    to:

    $fileinsert = array();    // initialize the variable before the loop
    
    ...
    $fileinsert[]=$filePath.$fileName;    // or just $fileName if you don't need the path in the DB
    

    and then you need to change:

    $name1=basename($_FILES['image01'][$fileName]);//the file name of the first actual jpg
    $name2=basename($_FILES['image02'][$fileName]);//the file name of the sencond actual jpg
    $name3=basename($_FILES['image03'][$fileName]);//the file name of the third actual jpg
    $name4=basename($_FILES['image04'][$fileName]);//the file name of the fourth actual jpg
    

    to:

    $name1=$fileinsert[0];
    $name2=$fileinsert[1];
    $name3=$fileinsert[2];
    $name4=$fileinsert[3];
    

    Something like that should do it.

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

Sidebar

Related Questions

I have included my two code sources below. The problem that I am having
I have a rails module included for reference below that I have included using
below i have a code that runs in most of my simple programs ..
I have this code that determines whether a word (ignoring case) is included in
I have a code that currently loads a NIB file like below : Login
I have included my source code draft below. I would appreciate any input on
I am trying to manipulate a string using Jython, I have included below an
I need to echo entire content of included file. I have tried the below:
Below I have written a sample program that I have written to learn about
I have below html code in my aspx. <input type=hidden id=medicalLink value='<a href=/forms/contactus.aspx >Contact

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.