I have tried to image copy one directory to another directory but it is not working for me.
Here is my code:
<?php
$old_sub_dir = '/media/import';
$new_sub_dir = '/media/catalog/product/image';
//get directory contents
$contents = array();
$dir = opendir($_SERVER['DOCUMENT_ROOT'] . $old_sub_dir);
while (false !== ($file = readdir($dir))) {
$contents[] = $file;
}
closedir($dir);
//get only jpeg contents
$jpeg_contents = array();
foreach($contents as $file){
if (eregi('.jpg{1}$', $file)){
$jpeg_contents[] = $file;
}
}
// copy each jpeg from directory 'a' to directory 'b'
foreach($jpeg_contents as $file){
copy($_SERVER['DOCUMENT_ROOT'] . $old_sub_dir . '/' . $file, $_SERVER['DOCUMENT_ROOT'] . $new_sub_dir . '/' . $file);
}
?>
and the error I'm getting is:
Uncaught Error: Call to undefined function eregi()
Any help would be appreciated.
Thanks.