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

Another CFIMAGE Bug?

Participant ,
Dec 05, 2008 Dec 05, 2008
I'm creating a catalog and I want the user to upload the items which includes a photo. I then store the photo and the other pieces of information in a database. I'm using the cfifle to upload the photo then use cfimage to get the photo info for the insert, I insert the record then I delete the photo from the folder I uploaded it to. Everything worked great. I then changed the destination on the cffile tag to a different location, since the first time I just wanted to see if it would work. The cfimage tag will bomb because it is looking for the photo in the old location and not the new one. The upload went fine to the new location. I cleared the cache, opened a new browser. Why would it still be looking for it in the old location. I change the cffile upload back to the first destination area and it works. Why can't I change the location of where to get the photo? Is cfimage not getting something cleared out?

thanks
2.4K
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

correct answers 1 Correct answer

Advisor , Dec 05, 2008 Dec 05, 2008
You might try providing the full path and file name to cfimage.

<cfset itemPhoto="#cffile.serverdirectory#\#cffile.serverfile#">
Translate
Participant ,
Dec 05, 2008 Dec 05, 2008
Hi

Can you provide us the code for reference
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
Participant ,
Dec 05, 2008 Dec 05, 2008
Here is the code of the upload and cfimage. The destination I want it to be is this "\inetpub\wwwroot\safety\recognition\photoArea. I'm on CF 8.1.


<cffile action="UPLOAD"
filefield="photo_name"
destination="\Inetpub\wwwroot\safety\recognition"
nameconflict="MAKEUNIQUE">
<cfif fileWasSaved EQ 'Yes'>
<cfelse>
<script language="JavaScript">
alert("Photo couldn't be uploaded to the server - Try again or contact the IT Dept.");
history.back();
</script>
<cfabort>
</cfif>
<cfset itemPhoto = file.ServerFile>
<cfimage action="read" source="#itemPhoto#" name="ItemAdded">
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 ,
Dec 05, 2008 Dec 05, 2008
You might try providing the full path and file name to cfimage.

<cfset itemPhoto="#cffile.serverdirectory#\#cffile.serverfile#">
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
Participant ,
Dec 05, 2008 Dec 05, 2008
I'll try that but I guess I don't understand. I'm using the same path as before but I want to go down one more level from where I was to write the image.
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 ,
Dec 05, 2008 Dec 05, 2008
quote:

Originally posted by: want-a-be
I'll try that but I guess I don't understand. I'm using the same path as before but I want to go down one more level from where I was to write the image.


I suggest using the absolute path since cffile and cfimage treat relative paths differently. In cffile path is relative to temp directory and for cfimage it is relative to web root.
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
Participant ,
Dec 05, 2008 Dec 05, 2008
Bob, thanks for the suggestion. That didn't work. I still have the same problem. It seems like it is in the cfimage tag not clearing out old information.
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 ,
Dec 05, 2008 Dec 05, 2008
Have you tried replacing cfimage with cffile action = "readBinary"?

Does the account running CF8 have both read and write access to the directory you are saving files to?
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 ,
Dec 05, 2008 Dec 05, 2008
Can you also post any error messages you are getting.
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
Participant ,
Dec 05, 2008 Dec 05, 2008
Here is my cffile tag:
<cffile action="UPLOAD"
filefield="photo_name"
destination="\Inetpub\wwwroot\safety\recognition"
nameconflict="MAKEUNIQUE">

now I want to write it to a sub directory of recognition

<cffile action="UPLOAD"
filefield="photo_name"
destination="\Inetpub\wwwroot\safety\recognition\photoArea"
nameconflict="MAKEUNIQUE">

the error I get is this:
File C:\Inetpub\wwwroot\safety\recognition\Ace_Hearts.jpg does not exist.

It does exist but the cffile wrote it to the photo area - cfimage file is looking at the parent directory for 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 ,
Dec 05, 2008 Dec 05, 2008
What happens if you hard code the directory?

<cfset itemPhoto= "C:\Inetpub\wwwroot\safety\recognition\photoArea\#cffile.ServerFile#">

I'm not suggesting you use this in production, I'm curious as to whether or not cfimage can read from the directory.
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 ,
Dec 05, 2008 Dec 05, 2008
You might also try using the ImageGetBlob function if you reading the image then inserting it into a database.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_h-im_23.html#5177242
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
Participant ,
Dec 05, 2008 Dec 05, 2008
I am using the ImageGetBlob on my insert statement. All of that works when I using the first directory that I used with cfimage.

I do have another forum message that is current in that I can't get the ImageGetBlob to work if the image is GIF. If it is a JPG then it works fine.
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
Participant ,
Dec 05, 2008 Dec 05, 2008
messing around more with the full path on the cfimage I found my problem. I didn't have the correct path I needed. Once I got that it is now working.

thanks for your time and help on this.
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
New Here ,
Dec 07, 2008 Dec 07, 2008
LATEST
Useful infor.
THANKS
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 ,
Dec 05, 2008 Dec 05, 2008
> I then changed the destination on the cffile tag to a different location
> ...
> <cfset itemPhoto = file.ServerFile>
> <cfimage action="read" source="#itemPhoto#" name="ItemAdded">

Yes, but where is your upload page located?

Since you are not passing cfimage an absolute path, it will look in the current directory. If your images are now in a _different_ directory, CF will not be able to find them unless you tell it where to look.

For example, if your upload page is in the recognition directory:
c:\Inetpub\wwwroot\safety\recognition\yourUploadPage.cfm

Cfimage will look in that directory because that is what you are telling it to do here:
<cfimage action="read" source="#itemPhoto#" name="ItemAdded">

If CF needs to look in a different directory, either use the correct relative path or an absolute path as JR "Bob" Dobbs suggested.
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