Thanks for the reply.
This is a test script, a part of a much larger one, to verify that it work on a production server.
I'm too tired to deal with this right now but in reply to your reply:
The file is in the root of the of public_html/sitename/.
Images is a folder within that folder.
The script is located in that same folder.
It works perfectly on localhost but fails on 2 different servers.
I'm not seeing a space in jpg; but just in case here is the full test script from what is working on localhost.
Code: Select all
<?php
//error_reporting(E_ALL);
// ini_set('display_errors', '1');
// localhost=PHP Version 7.4.1 server=version 5.6.x and then upgraded to 7.something
$page="2";
$name="Craps";
$filename = "./images/".$name."-".$page.".jpg ";
//$filename = "images/$name-$page.jpg ";
// $filename = $_SERVER['DOCUMENT_ROOT'] . "/kycasi-net/images/".$name."-".$page.".jpg "; // localhost tes
echo "<br>".$filename; // debug
// if (file_exists($filename)) { echo "<p align='center'><img src=".$filename.">"; }
if(file_exists($filename)) { echo "<br>what is wrong with this script?<p align='center'><img src='$filename'>"; }
else { echo "image does not exist"; }
echo "<br>";
echo "<p align='center'><img src=".$filename.">";
?>
In the real script which is also working fine on localhost the variables $page and $name are retrieved from the DB.
If the page is 2 the image shows. If 1 it does not. If 3 or greater it does not because there is no Craps-3.jpg.