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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:18:05+00:00 2026-05-31T22:18:05+00:00

i am having trouble trying to upload an image to a website, and update

  • 0

i am having trouble trying to upload an image to a website, and update the database with the address of the image. All of the other fields are being correctly added to the database, except for the image address, and the image is not being saved in the images folder. I have absolutely no idea whats wrong, and when i try to upload an image it echoes there was a problem uploading your file. Thanks a lot for the help.

<?php

 if($_REQUEST['submit'])
 {       
   function isChecked($chkname,$value)
       {
         if(!empty($_POST[$chkname]))
         {
            foreach($_POST[$chkname] as $chkval)
            {
                if($chkval == $value)
                {
                    return true;
                }
            }
          }
          return false;
        }


  $target = "~start/B7/images/";
  $target = $target . basename( $_FILES['photo']['name']);

  $age = $_POST["age"];
  $brand = $_POST["brand"];
  $model = $_POST["model"];
  $price = $_POST["price"];
  $vechicleType = $_POST["vechicleType"];
  $fuelType = $_POST["fuelType"];
  $transmition = $_POST["transmition"];
  $doorsNumbers = $_POST["doorsNumbers"];
  $mileage = $_POST["mileage"];  
  $pic = ($_FILES['photo']['name']);



  //Connect to the server
  $con = mysql_connect("*********", "*********", "*********")
  or die('Could not connect:' . mysql_error());

  // Select database
  mysql_select_db("*********", $con)
  or die('Could not select database');

// Select all the names from the database   
$checkName = mysql_query("SELECT * FROM users");

while ($number = mysql_fetch_array($checkName))
{
  $index = 0;   
  if (($number['user_name'] == $name) && ($number['password'] == $password) 
      || isset($_SESSION['test']))
  {
    $index = 1;
    $_SESSION['test']=$name;
$_SESSION['id']=$number['user_id'];   
   }
 }


  // Select all the names from the database   
  $checkName = mysql_query("SELECT * FROM used_cars");  




 if (!empty($model)) 
  {
    if(isChecked('extras', 'leather'))
       $leather = "yes";


if(isChecked('extras', 'airCon'))
   $airCon = "yes";

if(isChecked('extras', 'satNav'))
   $satNav = "yes";

if(isChecked('extras', 'parkingSensors'))
   $parking = "yes";



$insert1="INSERT INTO used_cars (manufacturer, model, price, image, vehicleType,
age, transmission, fuelType, doorsNumber, user_id, colour, mileage,
leatherSeat, navigatorSystem, parkingSensor, airConditioner) VALUES ('$brand', '$model', '$price', '$pic', '$vechicleType', 
'$age', '$transmition', '$fuelType', '$doorsNumbers', '$user_id', 
'$colour', '$mileage', '$leather', '$satNav', '$parking', '$airCon')";    




     if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
     {
       //Tells you if its all ok
       echo "The file was uploaded";
     }

     else
     {
       //Gives an error if its not
       echo "Sorry, there was a problem uploading your file.";
     }



   }

   else
   {
     echo 'Please fill in all fields';
   }




  mysql_close($con);
  } 
 ?>
  • 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-31T22:18:07+00:00Added an answer on May 31, 2026 at 10:18 pm

    As explained further in the comments, your path should probably be images/

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

Sidebar

Related Questions

I am having trouble trying to make a HashMap accessible to other methods in
I'm having trouble trying to figure out why my formatDate is not working correctly.
Having submitted a form with a file to upload, I'm having trouble trying to
Im having trouble trying to post data correctly using jQuery/AJAX I have the following...
I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because
I am having trouble trying to get iterators for inner sub-containers. Basically imagine this
I am having trouble trying to connect an Infopath 2007 form to an WCF
I'm having trouble trying to attach a custom tracking participant in workflow foundation 4.0.
I am having trouble trying to move sub nodes or parent nodes up or
I'm having trouble trying to manipulate music using buttons I can't seem to make

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.