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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:05:30+00:00 2026-05-29T07:05:30+00:00

I currently have this script where users (using a form where they can upload

  • 0

I currently have this script where users (using a form where they can upload up to seven images) can upload multiple images to a folder and the image name to my database, without any success. Please help.

if (isset($_POST['submit'])) { $ref_49 = $_POST['ref_49'];
    $name = $_POST['name'];
    $contact = $_POST['contact'];
    $email = $_POST['email'];
    $rent_sell = $_POST['rent_sell'];
    $heading = $_POST['heading'];
    $price = $_POST['price'];
    $limitedtextarea = $_POST['limitedtextarea'];
    $type = $_POST['type'];
    $where = $_POST['where'];
    $address = $_POST['address'];
    $bedroom = $_POST['bedroom'];
    $bathroom = $_POST['bathroom'];
    $garages = $_POST['garages'];
    $carports = $_POST['carports'];
    $granny_flat = $_POST['granny_flat'];
    $ref_99 = $_POST['ref_99'];
    $fulldesc = $_POST['full_desc'];

    if ($ref_99=="") {
    $full_ad = "yes";
    } else {
    $full_ad = "no";
    }
    $todays_date = date("Y-m-d");
     mkdir("gallery/" . $_POST["name"], 0777); 

for ($i = 0; $i < 7; $i++) 
{
    $file_name = $_FILES['uploadFile' . $i]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'", "", $file_name);
    // $copy = copy($_FILES['uploadFile'. $i]['tmp_name'], "gallery/" . $_POST["name"] . "/" . $file_name);

    if ((($_FILES['uploadFile' . $i]["type"] == "image/gif") 
      || ($_FILES['uploadFile' . $i]["type"] == "image/jpeg") 
      || ($_FILES['uploadFile' . $i]["type"] == "image/pjpeg")) 
      && ($_FILES['uploadFile' . $i]["size"] < 200000000)) 
    {
        if ($_FILES['uploadFile' . $i]["error"] > 0) 
        {
            $message = "Return Code: " . $_FILES['uploadFile' . $i]["error"] . "<br />";
        }
        else
        {
            $query = "INSERT INTO property (

                    name, contact, email, type_of_listing, rent_sell, address, prop_desc, area, price, main_image, image_1, image_2, image_3, image_4, image_5, image_6, heading, bathroom, bedroom, garages, carports, granny_flat, full_description, full_ad, 49_ref, 99_ref, listed 

                ) VALUES (

                    '{$name}', '{$contact}', '{$email}', '{$type}', '{$rent_sell}', '{$address}', '{$limitedtextarea}', '{$where}', '{$price}', '{$photo_1}', '{$photo_2}', '{$photo_3}', '{$photo_4}', '{$photo_5}', '{$photo_6}', '{$photo_7}', '{$heading}', '{$bathroom}', '{$bedroom}', '{$garages}', '{$carports}', '{$granny_flat}', '{$fulldesc}', '{$full_ad}', 'ref_49_{$ref_49}', 'ref_99_{$ref_99}', ''
                )";
            $result = mysql_query($query, $connection);

            if (file_exists("gallery/" . $_POST["name"] . "/" . $_FILES['uploadFile' . $i]["name"])) 
            {
                $message = "<h3>" . $_FILES['uploadFile' . $i]["name"] . " already exists.</h3>";
            }
            else
            {
                move_uploaded_file($_FILES['uploadFile' . $i]["tmp_name"], "gallery/" . $_POST["name"] . "/" . $_FILES['uploadFile' . $i]["name"]);
                $message = "File: " . $_FILES['uploadFile' . $i]["name"] . " uploaded.";
            }
        }
    }
    else
    {
        $message = "<h3>Invalid file or no file selected.</h3><br />• Only JPEG OR GIF allowed.<br />• Size limited may not exceed 200KB.<br /><a href = \"local_artist.php\">Return</a>";
    }
}
}

}
  • 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-29T07:05:31+00:00Added an answer on May 29, 2026 at 7:05 am

    There could be a lot of things going wrong here. Have you tried to break this up into pieces? Are you sure the DB is connecting? Are you sure php has access to write to the directories it’s attempting to write to? Are you sure those directories exist…etc. etc.

    Comment out the vast majority of the code, and start testing all the components piece by piece, or wrap stuff in try/catch and see what errors are produced.

    [edit]
    If the problem only occurs when you upload < 7 files then the problem is in that you’ve hard coded a 7 into your loop!

    Loop through how many files are actually being uploaded, not a fixed number.

    Assuming they’re all being named sequentially (and starting at 0) you can test for the existence of your hashed FILE value in the loop and just keep ingesting until it comes up null (probably good to add a limiter to make sure it can’t go on for ever)

    something like this…

    [edit 2] modified the condition to include a test for file size

    for($i=0;  $_FILES['uploadFile' . $i] && $_FILES['uploadFile' . $i]['size'] > 0 && $i<100 ; $i++){
      try{
        //do your upload stuff here
      }catch(e){}
    }
    

    [EDIT]
    To modify your page to include a dynamic number of fields do this:

    check out this fiddle: http://jsfiddle.net/RjcHY/2/

    Click the plus and minus buttons on the right side to see how it works. I made it so that it’s naming the file buttons as per your php’s expectations.

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

Sidebar

Related Questions

Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
Using dotnet 2.0. I currently have code like this : DataView dv = new
I currently have an asp form that uses jquery for two elements: an image
I currently have this working but it requires me to have a static method
I do not currently have this issue , but you never know, and thought
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
Currently i have this method: static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return
Currently i have this: $(.splitCol).click(function () { $.cookie('whichColumn', 'split'); $(.threeCol .active).removeClass(active); $(.leftCol .active).removeClass(active); $(.splitCol
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I have this command that I run every 24 hours currently. find /var/www/html/audio -daystart

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.