Trying to get php function getimagesize working

resulting page from code and errorHi.  I have been trying to get this to work for hours.  I can't see what I am doing wrong.  I am working on php4 on godaddy shared hosting.  I am trying to get the php function getimagesize working in a test php program so I can apply the logic to another program.

I displayed the file variable with an img tag to confirm the path to the image file was correct.

Here's my test page:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
$filename = "/webadmin/uploads_for_emails/smileyface.jpg";
echo "<img src='" . $filename . "'>";
echo "filename " . $filename;
list($width, $height, $type, $attr) = getimagesize($filename);

echo "Image width " .$width;
echo "<BR>";
echo "Image height " .$height;
echo "<BR>";
echo "Image type " .$type;
echo "<BR>";
echo "Attribute " .$attr;


Open in new window

I've attached a screenshot of the resulting page and error message.

Thanks for your help.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
The code works perfectly on my server here with both a file in the same directory and a file on my hosted web site.  Since your code is loading the image, there is something about your path that one of the routines doesn't like.  Try putting the image file in the same directory as the PHP file and see if it works.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alexisbrAuthor Commented:
Thanks, Dave.  You are right.  The problem was with the path.  When I tried putting the image in the same folder, it worked.  Apparently the routines don't like when you use the path from root.  I changed the path to start from the current folder, and then it worked.  Here's the change below that worked for both displaying the image and giving the width and height.  

$filename = "/webadmin/uploads_for_emails/smileyface.jpg";
$filename = "uploads_for_emails/smileyface.jpg";

I'm not sure why godaddy doesn't accept the other path but I'm glad to know how to get it to work.

Thank you again for your awesome help.

Dave BaldwinFixer of ProblemsCommented:
You're welcome.  I think it's just that PHP routine, not Godaddy.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

alexisbrAuthor Commented:
Thanks, Dave but I thought you said my original program worked fine as is on your system and on your host.  That's why I was saying the problem must be on godaddy's end that I had to change the way I did the paths.

Dave BaldwinFixer of ProblemsCommented:
The first thing I did with your code is change the image link to one in the same directory.  Then I changed it to an image on my web site.  Both worked fine so I figured it must be the path.  But your path worked to display the image but not with the getimagesize() function.  So the path worked in an <img> tag but not in the PHP function.  Both are still coming from Godaddy so I don't think it's a Godaddy problem.  Just some oddity in the way PHP was trying to use the path.
alexisbrAuthor Commented:
OK I understand now.  Thanks for the details.  I appreciate it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.