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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:09:45+00:00 2026-06-03T14:09:45+00:00

I am trying to upload an image to the server (with a path in

  • 0

I am trying to upload an image to the server (with a path in mysql table) twice through php with different names. One version of the image as “xxxx.png” and the other version of the image as “xxxxt.png”.

My php is:

<?php

if ($_FILES['photo']) {
  $target = "images/properties/";  
  $target = $target . basename( $_FILES['photo']['name']); 

  $pic = "images/properties/" .(mysql_real_escape_string($_FILES['photo']['name']));

  if (move_uploaded_file($_FILES['photo']['tmp_name'], $target)) {
    mysql_query("INSERT INTO `images` (`productcode`, `photo`) VALUES ('$productcode', '$pic' )");
    echo "The new image has been added successfully"; 
  } else { 
    echo "Error uploading new image - please check the format and size"; 
  }
}

?> 

The above code inserts the image into the mysql database and uploads the file to the server correctly.
I am however trying to upload the same image twice with a different naming convention on a “thumbnail” version. The slideshow script in my html only recognises the thumbnails if there are named with a “t” at the end of the filenames hence my problem.

I have been advised to look at the php copy() function to achieve this but am incredibly unclear as to how to incorporate such a function into my existing code.
Happy to provide the html or any other info if required.

Any help much appreciated. I did have another thread attempting to find out the same thing but I wasn’t very clear!

Thanks
JD

  • 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-03T14:09:47+00:00Added an answer on June 3, 2026 at 2:09 pm

    As you’ve been advised you should use copy(). I didn’t fully test this but give it a try:

    <?php
    
    if ($_FILES['photo'])
    {
        $target = "images/properties/";
    
        $ext = array_pop(explode('.', $_FILES['photo']['name']));
        $copy = $target . basename($_FILES['photo']['name'], '.' . $ext) . 't.' . $ext;
    
        $target = $target . basename($_FILES['photo']['name']);
    
        $pic = "images/properties/" .(mysql_real_escape_string($_FILES['photo']['name']));
    
        if (move_uploaded_file($_FILES['photo']['tmp_name'], $target))
        {
            copy($target, $copy);
            mysql_query("INSERT INTO `images` (`productcode`, `photo`) VALUES ('$productcode', '$pic' )");
            echo "The new image has been added successfully";
        }
        else
        {
            echo "Error uploading new image - please check the format and size";
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to resize one image to 5 different sizes (and then upload them
i am trying to upload a image to server from iPhone application PHP code
hi all i am trying to upload image file from sdcard to php server
I am trying to upload image file from my one server to another remote
I am trying to upload an image to the server. I hava a form
I am trying to upload an image to server using iphone . I haven't
I am trying to Upload image Capture by Camera into server. server send response
I'm trying to upload an image to my server and the destination attribute of
I am trying to upload an image to server using using XMLHttpRequest but fails.
I am trying to upload image on web server, but whenever it tries it

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.