Forum Moderators: coopster

Message Too Old, No Replies

copy problem

         

andrewsmd

12:44 pm on Oct 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all, I have some simple copy code assume $toBuild is a glob("some path");
assume that $buildArchive is a valid path and the function getFileName() returns the file name of a file
so hence $buildArchive\\$tempName is the copy path
It works fine until I start dealing with a large number of files something like 650.
Then I get an error in copying whatever file but when I look in the copy folder it is in there.
Does anyone know why it is erroring on me? Thanks

foreach($toBuild as $i){

$tempName = getFileName($i);

//copy the files to the archive
if(!(copy($i, "{$buildArchive}\\{$tempName}"))){

echo("There was an error in copying the file $tempName to the build archive.\\nThe files were not renamed.");
die();

}//if !copy

}//foreach

eelixduppy

2:59 pm on Oct 16, 2008 (gmt 0)



Are you getting any errors from PHP?

andrewsmd

4:23 pm on Oct 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No only my echo error. My error basically only echos if the copy returns false. So for some reason the copy is working and returning false. I have checked my glob and there are no empty subs, I only can guess that it has something to do with sheer number of files. Would I possibly need to cleaterstcache or whatever that function is?

eelixduppy

4:45 pm on Oct 16, 2008 (gmt 0)



If my memory serves me correctly, glob returns the following, as well: "." and ".." as well as directories. Copy does not move directories, so make sure you are omitting these.

Other than that, I do not know. It shouldn't have anything to do with the number of files. Do you know how many times the error messages start appearing? How far into the file iterations? Are they the same files every time? There's a bunch to look at here.

andrewsmd

5:15 pm on Oct 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My glob array are all completely valid files. It always returns an error on the last file it has to copy. The error message only appears once because I kill the program on an error.

eelixduppy

5:25 pm on Oct 16, 2008 (gmt 0)



So is it always dying on the same file? Are you sure you aren't getting any PHP errors? If it has anything to do with the number of files you are iterating through then there may either be a script timeout error, or a memory problem.

andrewsmd

5:41 pm on Oct 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How would I check for PHP errors the PHP server is on another machine. And it's not always the same file I deleted the file it was erroring on and then it errored on the file that was the last file in the new glob.