Jump to content

getimagesize issue


son
 Share

Recommended Posts

Using the getimagesize i just changed it to include a variable instead of the file including path as text. I have it as

getimagesize("{$imgMainPathComplete})"also triedgetimagesize("$imgMainPathComplete")

but get errorfailed to open stream: Connection refused The path including file name is correct. Where am I going wrong? To use variables would make my life so much easier...Son

Link to comment
Share on other sites

Connection refused means the remote server you're contacting refused the connection you're trying to make.And, in general, there's no reason to arbitrarily put a variable in quotes.getimagesize($imgMainPathComplete)
My issue is that I do not know why the absolute pathlist($imgWidth, $imgHeight) = getimagesize($ImagePathFull); -> which shows the correct path, which I double-checked in copying from error message and pasting in browserdoes not work, but the relative pathlist($imgWidth, $imgHeight) = getimagesize("../images/main/{$img1}");works.Is there a server setting that can require relative paths or so?Cheers,Son
Link to comment
Share on other sites

If you're accessing the file over HTTP then different rules apply versus accessing a local file. The relative path is local, I don't know what you're using for the full path.
The file is sitting on live web server, the absolute path ishttp://www.domain.co.uk/images/main/ plus $img1 (as I said leads correctly to file when copied)Could it be a general server setting to not allow absolute paths for this function? Am not sure if that is possible...Son
Link to comment
Share on other sites

This has nothing to do with absolute paths versus relative paths. It has everything to do with accessing an image over HTTP versus a local file. Like I said, HTTP files are handled completely differently than local files. A relative path is always local when you're dealing with PHP. Your server is apparently having problems communicating with itself, assuming you're trying to access a file on the same server. Use a local filesystem path instead of the HTTP path. You can either use an absolute local path or a relative local path.Again, this has nothing to do with absolute versus relative paths, and nothing to do with literal values versus variables. This is an issue of local files versus remote files. You're telling it to open a remote file, even if the file is actually on the same machine.

Link to comment
Share on other sites

This has nothing to do with absolute paths versus relative paths. It has everything to do with accessing an image over HTTP versus a local file. Like I said, HTTP files are handled completely differently than local files. A relative path is always local when you're dealing with PHP. Your server is apparently having problems communicating with itself, assuming you're trying to access a file on the same server. Use a local filesystem path instead of the HTTP path. You can either use an absolute local path or a relative local path.Again, this has nothing to do with absolute versus relative paths, and nothing to do with literal values versus variables. This is an issue of local files versus remote files. You're telling it to open a remote file, even if the file is actually on the same machine.
I am finally with you. When I spoke of absolute I mistakenly meant 'http://www.' etc. Checked it now with the correct absolute path and it is working now:-)Many thanks,Son
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...