Warning: imagecreatefromjpeg(/web/uploads/orig.jpeg): failed to open stream: No such file or directory in C:\xamppNew\htdocs\photo\thumbimage.class.ph

mallett76

Member
When I run the following code:
<?php
// example.php
#require_once $_SERVER['DOCUMENT_ROOT'].'/common/configs/config_templates.inc.php';
require "thumbimage.class.php";
/* $objThumbImage = new ThumbImage("/web/uploads/orig.jpg");
$objThumbImage->createThumb("/web/uploads/thumb.jpg", 125); */
$objThumbImage = new ThumbImage("/web/uploads/orig.jpeg"); // IMPORTANT - THIS LINE WORKS FINE
$objThumbImage->createThumb("/web/uploads/thumb.jpeg", 125);
?>

I receive the following error
Warning: imagecreatefromjpeg(/web/uploads/orig.jpeg): failed to open stream: No such file or directory in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 12

Warning: imagesx() expects parameter 1 to be resource, bool given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 13

Warning: imagesy() expects parameter 1 to be resource, bool given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 14

Warning: Division by zero in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 15

Warning: imagecreatetruecolor() expects parameter 2 to be int, float given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 16

Warning: imagecopyresampled() expects parameter 1 to be resource, null given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 17

Warning: imagejpeg() expects parameter 1 to be resource, null given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 18

Warning: imagedestroy() expects parameter 1 to be resource, bool given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 19

Warning: imagedestroy() expects parameter 1 to be resource, null given in C:\xamppNew\htdocs\photo\thumbimage.class.php on line 20

The files - like orig.jpeg - in question appear to be there, so, I'm confused by the error.
 
The error message you're encountering suggests that the script is unable to locate the file orig.jpeg in the specified directory.
You can add some debugging statements in your PHP code to output the path being used and verify if it matches the expected path.

<?php
$filePath = "/web/uploads/orig.jpeg";
if (file_exists($filePath)) {
echo "File exists: $filePath";
} else {
echo "File does not exist: $filePath";
}
?>

By checking these steps, you should be able to identify and resolve the issue causing the script to fail to locate the file. i hope it will solve your issue.
 
The error message you're encountering suggests that the script is unable to locate the file orig.jpeg in the specified directory.
You can add some debugging statements in your PHP code to output the path being used and verify if it matches the expected path.

<?php
$filePath = "/web/uploads/orig.jpeg";
if (file_exists($filePath)) {
echo "File exists: $filePath";
} else {
echo "File does not exist: $filePath";
}
?>

By checking these steps, you should be able to identify and resolve the issue causing the script to fail to locate the file. i hope it will solve your issue.
Thank you, I will give your suggestion a try.
 
Back
Top