Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFimage erro

Advisor ,
Feb 10, 2010 Feb 10, 2010

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

1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 10, 2010 Feb 10, 2010

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#

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 10, 2010 Feb 10, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 10, 2010 Feb 10, 2010
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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 10, 2010 Feb 10, 2010

Hi,

1. The value is fine because it works on and off.

2. I'm attaching the image. ( The image is fine)

Thanks!

Johnny

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 10, 2010 Feb 10, 2010

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 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 10, 2010 Feb 10, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 10, 2010 Feb 10, 2010

Line numbers in error messages are not always accurate. Can you post the full code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 10, 2010 Feb 10, 2010

Here is the code.

Is this available to the public?

I would like no to share this for security reasons.

Thanks!

Johnny

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 10, 2010 Feb 10, 2010

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==-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2010 Feb 10, 2010

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()>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 11, 2010 Feb 11, 2010

That works!

Thanks for you help... looks like sometimes the session variable is blank.

Regards

Johnny

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 11, 2010 Feb 11, 2010

>> 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 11, 2010 Feb 11, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 11, 2010 Feb 11, 2010
LATEST

Application.url is a session variable

Ummm.. that is an application variable, not a session variable.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources