Jump to content

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct


iNealec

Recommended Posts

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 ) ;
?>

I have also just found an error_log file containing this if it helps.

 

[12-Mar-2014 18:07:18 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
[12-Mar-2014 18:07:18 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/imagick.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0
[12-Mar-2014 18:07:18 UTC] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(GeneratedBundles/20140312180718/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

RecursiveDirectoryIterator::__construct(GeneratedBundles/20140312173738/bundles/): failed to open dir: No such file or directory

The problem is the directory doesn't exist.

 

[12-Mar-2014 18:07:18 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0

[12-Mar-2014 18:07:18 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/imagick.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0

There's a problem with your installation. If you're not the one administering the server then you should pass these messages along to whomever does. If you are, how familiar are you with setting up PHP?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.