Hi all,

I'm using @copy to copy large files from one server to another and it usually works fine.

Occasionally it stops mid way through though and I have to start again. So I wondered if anyone knows of a way php can read my half copied file, compare it to the original and continue copying the remaining data adding it to the file so it's exactly like the original?

The files being copied are usually zips but some are video and autio files.

Many Thanks!

If you can read the half copied file, get it's size and append to it, then yes, it should be possible, but not with copy. You'd need to use fseek/fread/fwrite.

If you can read the half copied file, get it's size and append to it, then yes, it should be possible, but not with copy. You'd need to use fseek/fread/fwrite.

Thanks

I'm figuring I'll be able to read the half copied local file. It's copying the the missing half from the remote server and appending it into the local file that might be more difficult (for me).

From what I can tell I need to check if the socket connection was broken (stream_set_timeout maybe), if it was find the last point of the local file, re-establish the connection to the remote server file, seek the point it stopped at and append it to the local file. I gather with the fseek/fread/fwrite you mentioned.

I'll keep looking. Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.