Solved

cfimage not working

Posted on 2008-10-07
6
256 Views
Last Modified: 2011-09-20
can someone tell me why this isnt working??? I ma gettin an error that says the destination directory doesnt exist  but it does!


<cfset imagename = listlast(form.filename,"\")>


<cfif #IsDefined("FORM.file")# AND #FORM.file# IS NOT ''>              
<cffile
action="UPLOAD"
filefield="form.file"
destination="c:\websites\171210jc2\admin\events\#session.folderpath#\#imagename#"
nameconflict="makeunique">  

<cfimage action="info" structname="imagetemp" source="c:\websites\171210jc2\admin\events\#session.folderpath#\#imagename#">
<cfset x=min(200/imagetemp.width, 100/imagetemp.height)>
<cfset newwidth = x*imagetemp.width>
<cfset newheight = x*imagetemp.height>
<cfimage action="resize"
source="c:\websites\171210jc2\admin\events\judsonmusic\#imagename#"
width="#newwidth#"
height="#newheight#"
destination="c:\websites\171210jc2\admin\events\judsonmusic\Thumb_#imagename#">

</cfif>
0
Comment
Question by:judsonmusic
  • 4
  • 2
6 Comments
 
LVL 3

Author Comment

by:judsonmusic
ID: 22663539
ACTUALLY I CHANGES MY CODE TO THIS:

<cfif #IsDefined("FORM.file")# AND #FORM.file# IS NOT ''>              
    <cffile
    action="UPLOAD"
    filefield="form.file"
    destination="c:\websites\171210jc2\admin\events\#session.folderpath#\#imagename#"
    nameconflict="makeunique">  
   
    <cfoutput>
    <cfimage source="c:\websites\171210jc2\admin\events\#session.folderpath#\#imagename#"
    action="resize"
    width="150"
    height="200"
    destination="c:\websites\171210jc2\admin\events\#session.folderpath#\thumb_#imagename#"
    overwrite = "true">
    </cfoutput>
   
</cfif>


IT WORKS ON A WINDOWS MACHINE BUT NOT ON A MAC! WHY???:::::::::::::::::::::::::::::::::::::

When i run it on a mac I get the following error:

 An exception occured while trying to write the image.
Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : java.lang.NullPointerException
 
The error occurred in C:\Websites\171210jc2\admin\myEvents.cfm: line 25

23 :     width="100"
24 :     height="100"
25 :     destination="c:\websites\171210jc2\admin\events\#session.folderpath#\#imagename#"
26 :     overwrite = "true">
27 :     </cfoutput>

0
 
LVL 3

Author Comment

by:judsonmusic
ID: 22664354
I have narrowed it down to safari.

Safari doesnt like this:

<cfset imagename = listlast(form.filename,"\")>

it outputs the full path for some reason but in FF and IE is just shows the file name.

WHY?????
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 22664912
For the ipload destintaion you do not add the imagename. Destination is a folder not a file.
The resulting file name can be retrieved from cffile variable.
Like this:

<cfif IsDefined("FORM.file") AND FORM.file IS NOT '' >              

<cffile 

action="UPLOAD" 

filefield="form.file" 

destination="c:\websites\171210jc2\admin\events\#session.folderpath#\" 

nameconflict="makeunique">  
 

<cfset imageName = "#cffile.serverFile#.#cffile.serverFileExt#" >
 

<cfimage action="info" structname="imagetemp" source="c:\websites\171210jc2\admin\events\#session.folderpath#\#imageName#">

<cfset x=min(200/imagetemp.width, 100/imagetemp.height)>

<cfset newwidth = x*imagetemp.width>

<cfset newheight = x*imagetemp.height>

<cfimage action="resize" 

source="c:\websites\171210jc2\admin\events\judsonmusic\#imageName#" 

width="#newwidth#" 

height="#newheight#" 

destination="c:\websites\171210jc2\admin\events\judsonmusic\Thumb_#imageName#">
 

</cfif>

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 3

Author Comment

by:judsonmusic
ID: 22665068
thats seems so work now I have 2 other questions I am going to post if you can help me with those as well???
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 22666278
We will see. I assume I will be able to help :-)

But please take a look one moment at the actual question. You replied that it "seams" to work. That is not acceptable. The purpose of my support is to get you learning from your question not to do your job and get your code working.
So my question to you is: do you see what mistakes you made in your code and did you learn what is the correct way of uploading files and generating server side uploaded file names?
0
 
LVL 3

Author Comment

by:judsonmusic
ID: 22666342
yes it worked perfectly Im sorry
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Converting CFGRID from Flash to HTML in Coldfusion 1 90
<cfquery> to Excel 5 56
C# script to Coldfusion 25 59
popup load of page and setting up of session 8 26
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now