Copy link to clipboard
Copied
Hello,
I just update from CF7 to CF9 standard version and start using cfimage.
<cfset tempPath = "c:/images/#cffile.serverFile#" />
<cfset uploadedImage = "" />
<cfimage action="read" source="#tempPath#" name="uploadedImage"/>
<cfset headingWidth = uploadedImage.GetWidth() />
<cfset headingHeight = uploadedImage.GetHeight() />
I got this error pointing to cfimage line:
Detail | javax.imageio.IIOException: Can't get input stream from URL! |
Message | An exception occurred while trying to read the image. |
Any ideas?
Thanks!
Johnny
Copy link to clipboard
Copied
Strange, I would not expect that error from a local file.
1) Is that the exact code you used or is there other code on the page?
2) Does the error occur with all images, or just that one?
3) Did you use FileExists() to verify the image path is valid? ie #tempPath#
Copy link to clipboard
Copied
Hello,
Thanks for you reply and help.
1. In my path I'm using: <cfset tempPath = "#application.url#/sigs/#cffile.serverFile#" />
But I check the result and it's fine.
2. Just for some images, not for all.
3.Yes, I'm checking for the file before if the file is not there, abort the process.
Regards
Johnny
Copy link to clipboard
Copied
1. In my path I'm using: <cfset tempPath = "#application.url#/sigs/#cffile.serverFile#" />
What is the value of #application.url# ? With the images that fail, does it happen consistently? If so, can you upload one of them so we can test it.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The image works fine for me with CF9. Also, did you say you had or had _not_ verified the image path with FileExists()? That is an important step in troubleshooting. Even if you think the file exists, verify it anyway to avoid overlooking possible causes 😉
Copy link to clipboard
Copied
Yes, I'm checking the fileExist(), also using cftry to see if it an error but everything is fine.
The error point to the line of cfimage.
Any other ideas?
Thanks!
Johnny
Copy link to clipboard
Copied
Line numbers in error messages are not always accurate. Can you post the full code?
Copy link to clipboard
Copied
Here is the code.
Is this available to the public?
I would like no to share this for security reasons.
Thanks!
Johnny
Copy link to clipboard
Copied
Is this available to the public?
Yes. It is a public site. If you can access these forums, so can everyone else 😉 Just xxx out anything confidential. (I am assuming the problem code is not huge ...)
Message was edited by: -==cfSearching==-
Copy link to clipboard
Copied
Is this any better
<cfset tempPath = cffile.serverDirectory & "\" & cffile.serverFile>
<cfimage action="read" source="#tempPath#" name="uploadedImage"/>
<cfset headingWidth = uploadedImage.GetWidth()>
<cfset headingHeight = uploadedImage.GetHeight()>
Copy link to clipboard
Copied
That works!
Thanks for you help... looks like sometimes the session variable is blank.
Regards
Johnny
Copy link to clipboard
Copied
>> That is an important step in troubleshooting. Even if you think
>> the file exists, verify it anyway to avoid overlooking possible causes
Thanks for you help... looks like sometimes the session
variable is blank.
Hmm.. there are no session variables in the code you posted. But that is why it is important to post the actual code you are using and to verify all variables and assumptions in your code. I suspect you did not do that, or you probably would have identified the issue sooner But I am glad everything is working for you now.
Copy link to clipboard
Copied
Application.url is a session variable, is set on the application.cfc.
I put an email tag to sent me the value all the time we try and sometimes came blank.
Thanks for your help!
Johnny
Copy link to clipboard
Copied
Application.url is a session variable
Ummm.. that is an application variable, not a session variable.