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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:35:57+00:00 2026-05-31T06:35:57+00:00

Given a simple code like : $file = ‘hugefile.jpg’; $bckp_file = ‘hugeimage-backup.jpg’; // here

  • 0

Given a simple code like :

$file = 'hugefile.jpg';
$bckp_file = 'hugeimage-backup.jpg';
// here comes some manipulation on $bckp_file.

The assumed problem is that if the file is big or huge – let´s say a jpg – One would think that it will take the server some time to copy it (by time I mean even a few milliseconds) – but one would also assume that the execution of the next line would be much faster ..
So in theory – I could end up with “no such file or directory” error when trying to manipulate file that has not yet created – or worse – start to manipulate a TRUNCATED file.

My question is how can I assure that $bckp_file was created (or in this case -copied) successfully before the NEXT line which manipulates it .

What are my options to “pause” , “delay” the next line execution until the file creation / copy was completed ?

right now I can only think of something like

if (!copy($file, $bckp_file)) {
    echo "failed to copy $file...\n";
}

which will only alert me but will not resolve anything (same like having the php error)

or

if (copy($file, $bckp_file)) {
  // move the manipulation to here ..
}

But this is also not so valid – because let´s say the copy was not executed – I will just go out of the loop without achieving my goal and without errors.

Is that even a problem or am I over-thinking it ?
Or is PHP has a bulit-in mechanism to ensure that ?
Any recommended practices ?
any thoughts on the issue ? ??

  • 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-31T06:35:59+00:00Added an answer on May 31, 2026 at 6:35 am

    What are my options to “pause” , “delay” the next line execution until the file is creation / copy was completes

    copy() is a synchronous function meaning that code will not continue after the call to copy() until copy() either completely finishes or fails.

    In other words, there’s no magic involved.

    if (copy(...)) { echo 'success!'; } else { echo 'failure!'; }
    

    Along with synchronous IO, there is also asynchronous IO. It’s a bit complicated to explain in technical detail, but the general idea of it is that it runs in the background and your code hooks into it. Then, whenever a significant event happens, the background execution alerts your code. For example, if you were going to async copy a file, you would register a listener to the copying that would be notified when progress was made. That way, your code could do other things in the mean time, but you could also know what progress was being made on the file.

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

Sidebar

Related Questions

This is some simple JavaScript code I would like to implement, butit does not
Given this sample code: #include <iostream> #include <stdexcept> class my_exception_t : std::exception { public:
Given the sample code: class Base { public: bool pub; protected: bool prot; };
This very simple code gives me tons of errors: #include <iostream> #include <string> int
who can give me a simple code , i want a simplest way to
Given the following code sample: uint8_t i, in, ni; i = in = 2;
Simple sum of digits code. It compiles but when executed, the last cout gives
Can anybody give me some sample source code showing how to connect to a
Given a simple statement, such as: <statement id=SelectProducts resultMap=???> SELECT * FROM Products </statement>
I have to implement a webservice client to a given WSDL file. I used

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.