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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:42:01+00:00 2026-06-05T08:42:01+00:00

i am working on a website, in which each user can upload multiple images..i

  • 0

i am working on a website, in which each user can upload multiple images..i am able to upload the image and storing in a folder but i have a problem when two different user have the same image name, as i am storing image in a single folder. In the database where ,i am storing information, serial no is the unique key..i want to rename the image with adding serial no. with the image name to make it unique…please help me..to do it..

my form is as:-

<form action="upload_file.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" /> </br><br/>
<input id="submit" type="submit" value="submit" />

and upload_file.php is as:-

require_once('dbconnect.inc.php');
$db_name="uploaddata";
$tbl_name="data";
$db_selected=mysql_select_db("$db_name")or die("cannot select DB");
if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/pjpeg"))
    && ($_FILES["file"]["size"] > 0))
 {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    $Image_name=$_FILES["file"]["name"];
    $Image_type=$_FILES["file"]["type"];
     //upload is the folder of storing images       
     if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
     $_SESSION['response'] = " already exists please give some different name ";
     header("Location: testimage.php");
      }
    else
      {

      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
             $login_data="INSERT INTO $tbl_name(Image_name,Image_type) VALUES('$Image_name','$Image_type')";

        $login_result=mysql_query($login_data) or die(mysql_error());
        header("Location: abc.php");
          }
    }
  }
  • 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-05T08:42:04+00:00Added an answer on June 5, 2026 at 8:42 am

    You can use move_uploaded_file function to change name of destination file e.g.

    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $serial_number . '_' . $_FILES["file"]["name"] . );
    

    You can also use this function

    bool rename ( string $oldname , string $newname [, resource $context ] );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a website on which we have use parallax effect. In
I'm working on a website in which I should take data from a user
I'm working on a shopping cart in a website and I have my items(which
I'm working in the website of an AI competition, where you can upload either
I am working on is a website which features: user signup user login add
I am working on a website (Asp.net mvc), where I have multiple partial views.
I'm working on a website which has advert banners which link to external pages.
i am working on a website which deploy on web farms to serve high
I am currently working on a website which lists the businesses as per either
I am working on a website on which i show restaurants according to either

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.