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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:42:49+00:00 2026-06-12T20:42:49+00:00

I am trying to upload an image and at the same time copy the

  • 0

I am trying to upload an image and at the same time copy the file to another directory where i hope to then create that into a thumbnail size image.

The idea is to basically build a dynamic photo album so the output is a loop of images thats gets automatically updated every time someone uploads to it.

The main image i can upload without any problems, and the output loop is also easy. But i would love to be able to copy and thumb the image at the same time I upload and insert the file, file name and info to the directory and DB.

I have been trying to run a copy after the files uploads and then i was planning to test a Imagick to thumb the second img. But i havent even got around to testing the thumb yet because my copy doesnt work.

If all else fails I will just have to use Timthumb but I would expect that to load much slower on the output page. Does anyone have any issues with Timtumb? That would be a hell of a lot easier. 🙂

Basically I have this

if(move_uploaded_file($_FILES['thefile']['tmp_name'], 'uploads/' . $_FILES['thefile']['name'])) {
        $photo_filename = $_FILES['thefile']['name'];
        $query = "INSERT INTO gallery_photos (
                    photo_filename
                ) VALUES (
                    '{$photo_filename}'
                )";
        $result = mysql_query($query, $connection);
        $path = 'http://mydomain.com/directory/uploads/';
        $fpath = $path.$photo_filename;
        $dest = 'http://mydomain.com/directory/thumbs/';
        $fdest = $dest.$photo_filename;
        copy($fpath, $fdest);
        if ($result) {
            redirect_to("new_photo.php?upload=4");
        } else {
            echo "<p>Dude. Something went wrong!</p>";
            echo "<p>" . mysql_error() . "</p>";
        }
    }

I tried several variations of this, i placed the copy above the SQL and below, I also tried it without the $path/$dest variables i also tried it originally without the full path. But none of them worked.

The main pics are being uploaded to the uploads folder though. Its just not getting copied. The DB is getting updated no worries too.

Any help will be much appreciated.

Cheers

  • 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-12T20:42:50+00:00Added an answer on June 12, 2026 at 8:42 pm

    I think your copy process should look like this

    $path = __DIR__; // Full Path to site NOT URL 
    $fpath = $path . "/uploads/" . $photo_filename;
    $fdest = $path . "/thumbs/" . $photo_filename;
    
    if (! is_file($fpath))
        trigger_error("File Does not exist");
    
    if (!is_writable(dirname($fdest)))
        trigger_error("Can not Write to Destination");
    
    copy($fpath, $fdest);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Max file number can php upload at same time I'm trying to
I'm trying to upload an image file from an android device to my drupal
I have this Form I am trying to upload my image but every time
I am trying to upload an image to a directory on a server. i'm
I'm trying to make two forms that aren't displayed at the same time. The
i'm trying upload image and mp3 in the same form but image is uploaded
I am trying to upload a file and an image using the google drive
i am trying to upload an image from a jsp page using servlet. but
I am trying to upload an image to the server. I hava a form
I am trying to upload a image which i am clicking with the help

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.