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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:46:02+00:00 2026-06-17T23:46:02+00:00

i trying to set up a form that allows a users to upload an

  • 0

i trying to set up a form that allows a users to upload an image to a folder on a server and the tags with it to a database so that images can be searched the tags and any selected image would display a list of tags connected to it.
im trying to do a tag system like on stackoverflow just with images instead of text.
this is what i have so far:

<form action="insert.php" method="post">
<p>
<label for="file">Filename:</label>
<input type="file" name="imageName" id="imageName">
<br />
<label for="tags">Tags</label>
<textarea name="tags" id="tags" cols="45" rows="5"></textarea>
<input type="hidden" name="member" id="member" />
<br />
<input type="submit">
</p>
</form>

thats the form and this is the php

<?php
$con = mysql_connect("localhost");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("images", $con);

$sql="INSERT INTO images (imageName, tags, member)
VALUES
('$_POST[imageName]','$_POST[tags]','$_POST[member]')";

if (!mysql_query($sql,$con))
 {
 die('Error: ' . mysql_error());
 }
echo "1 record added";

mysql_close($con);

     $allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000000000000000000000)
&& in_array($extension, $allowedExts))
 {
  if ($_FILES["file"]["error"] > 0)
   {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    }
   else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
     else
     {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
     }
    }
else
   {
   echo "Invalid file";
  }

  ?>
  • 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-17T23:46:03+00:00Added an answer on June 17, 2026 at 11:46 pm

    You can do it by different ways:

    Using Simple HTML drop-down list (with option allow multiple selection)

    <select multiple="multiple" name="Select1" style="width: 129px">
    <!-- start loop here-->
    <option value="tag1">tag1</option>
    <!-- end loop here-->
    </select>
    

    Here you need to load all tags from database.

    OR
    Use jQuery UI Autocomplete

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

Sidebar

Related Questions

I am trying to set a default image for my image upload form. In
I am developing a form that allows the user to upload images as well
I'm currently trying to make a form called countcash that allows users to input
I'm trying to set up an html form that allows the user to select
I'm trying to create a form that will allow users to edit data. I
I am trying to build a relatively simple search form that allows the user
I'm trying to write an html/javascript set (to be interpreted in PHP) that allows
I'm trying to create a script that would allow the user to upload images
I'm trying to set up a form where the user can click on a
I'm working on something that allows users to edit a form they've submitted and

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.