I have a php script that works fine on my PC from wampserver but when I uploaded it and ran from my web server I get this error.
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(GeneratedBundles/20140312173738/bundles/): failed to open dir: No such file or directory' in /public_html/myserver.com/RandIconBase/merge.php:13 Stack trace: #0 /public_html/myserver.com/RandIconBase/merge.php(13): RecursiveDirectoryIterator->__construct('GeneratedBundle...') #1 {main} thrown in/public_html/myserver.com/RandIconBase/merge.php on line 13
Here is the code...
<?php
$baseType = "PresetBases/Pastel";
$rootpath = 'bundles/';
$date = date('YmdHis');
mkdir('GeneratedBundles/'.$date, 0700);
$zip = new ZipArchive;
if ($zip->open('Bundles.zip') === TRUE) {
$zip->extractTo('GeneratedBundles/'.$date.'/');
$zip->close();
}
$fileinfos = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator('GeneratedBundles/'.$date.'/'.$rootpath));
foreach($fileinfos as $pathname => $fileinfo) {
if (!$fileinfo->isFile()) continue;
$file = new SplFileInfo($pathname);
$ext = $file->getExtension();
if ($ext == 'png'){
$glyph = imagecreatefrompng($pathname);
list($gw, $gh) = getimagesize($fileinfo);
if($gw==120){
$baseimg = rand(1,17);
$filename = $baseType.'/'.$baseimg.'.png';
$heightWidth = 120;
list($width, $height) = getimagesize($filename);
$newwidth = $heightWidth;
$newheight = $heightWidth;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefrompng($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$img = imagecopy($thumb, $glyph, 0, 0, 0, 0, 120, 120);
imagepng($thumb, $pathname);
imagedestroy($thumb);
imagedestroy($glyph);
}
else if ($gw == 152){
$baseimg = rand(1,17);
$filename = $baseType.'/'.$baseimg.'.png';
$heightWidth = 152;
list($width, $height) = getimagesize($filename);
$newwidth = $heightWidth;
$newheight = $heightWidth;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefrompng($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$img = imagecopy($thumb, $glyph, 0, 0, 0, 0, 152, 152);
imagepng($thumb, $pathname);
imagedestroy($thumb);
imagedestroy($glyph);
}
}
}
header( 'Location: archive.php?folder='.$date ) ;
?>