You are here: copy($source, $destination) not working for me « PHP Programming Language « IT news, forums, messages
copy($source, $destination) not working for me

Posted by eholz1 on 01/23/07 04:30

Hello PHP group,

I am trying to use the copy function to copy files from one directory
to another.
This does not seem to work for me. What am I missing?

Below is the code I am using.

<?php
$filecount = 0;
$filelist[0] = '';
$idx = 0;

//define('loc1', '/usr/local/Apache2/htdocs/portfolios', true);
$path = 'testimage';
$thumb_path = 'thumbs';

$dir_handle = @opendir($path) or die("Unable to open directory
$path");

//$filename2 = $filename . '.old';
//copy($filename, $filename2);

while ($file = readdir($dir_handle))
{
$filetyp = strtolower(substr($file, -3));
if ($filetyp == 'jpg' )
{
//loc1. '/'.$path. '/' .$thumb_path . '/' .
$filelist[$idx] = $path . '/' . $file;
$thumbfile = $thumb_path . '/'. 'thumb-'. $file;

if (!@copy($file, $thumbfile)) {
echo "unable to copy file" .'<br>';
}

$idx++;
$filecount++;

}
}

closedir($dir_handle);

echo '<h2>'."counted: " . $filecount . " files.".'</h2>';

?>
I have tried to copy to the same directory as well - no luck. the
webserver has access to the folders in question. What do I need to do
to get this to work?

Thanks Again,

eholz1

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация