Getting an error with a cfile read action

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Getting an error with a cfile read action

    I am trying to get the image width and height using <cfile> I keep getting
    this error message.
    An error occurred when performing a file operation READ on file
    Portfolio\images\1\a.jpg.
    The cause of this exception was: java.io.FileNotFoundException:
    Portfolio\images\1\a.jpg (The system cannot find the path specified).

    The Error Occurred in C:\CFusionMX\wwwroot\hunter\ImagesTest.cfm: line 81

    79 : <tr height="110" valign="top">
    80 : <td valign="top" align="center" bgcolor="##E1DCEC" width="136">
    81 : <cffile action="READ" file="Portfolio\images\1\#ImageName#"
    variable="JPG">
    82 : <CFSET Width="#JPG#">
    83 : <CFSET Height="#JPG#">

    Here is my code. I want to be able to pass these variables to the popup
    window so that the window will open to the exact size of the image.

    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfparam name="PageNum_photocontest" default="1">
    <cfquery name="photocontest" datasource="hmddb">
    SELECT *
    FROM Test
    </cfquery>

    <cfset MaxRows_photocontest=2>
    <cfset
    StartRow_photocontest=Min((PageNum_photocontest-1)*MaxRows_photocontest+1,Max(ph
    otocontest.RecordCount,1))>
    <cfset
    EndRow_photocontest=Min(StartRow_photocontest+MaxR ows_photocontest-1,photocontes
    t.RecordCount)>
    <cfset
    TotalPages_photocontest=Ceiling(photocontest.Recor dCount/MaxRows_photocontest)>

    <!-- Auto Resize Window To Image Size -->
    <script language="Javascript">
    function PopupPic(sPicURL) {
    window.open( "popup.cfm?"+sPicURL, "",
    "resizable=1,HEIGHT=200,WIDTH=200");
    }
    </script>

    <script language="javascript">
    <!--
    //Make graphic fit in to specified space
    function makeFit(theImg, maxW, maxH){
    var oldH, oldW, chngH, chngH
    oldH = theImg.height;
    oldW = theImg.width;
    chngW = oldW/maxW;
    chngH = oldH/maxH;
    if(chngW > chngH) {
    theImg.width = maxW;
    }
    else if(chngH > chngW){
    theImg.height = maxH;
    }
    else {
    theImg.width = maxW;
    }
    document.getElementById('thisImage').style.display = '';
    }


    //-->
    </script>

    </head>

    <body>
    <table width="427" align="center" bgcolor="#523F76">
    <tr>
    <td align="center" class="headlineSM"><a href="rules.cfm"
    class="headlineSM">Complete
    Rules Here</a></td>
    </tr>
    </table>

    <table width="431" border="0" align="center" cellpadding="0" cellspcing="0">
    <!--- Set default value to use in our loop --->
    <cfset EndRow=0>
    <!--- Set the max number of record to display per row. --->
    <cfset ToDisplay=3>
    <!--- Start loop and define the stop point --->
    <cfloop condition="EndRow lt photocontest.RecordCount">
    <!--- Set the conditions for our inner loop --->
    <cfset StartRow=EndRow+1>
    <cfset EndRow=EndRow+ToDisplay>
    <cfif EndRow gt photocontest.RecordCount>
    <cfset EndRow = photocontest.RecordCount>
    </cfif>
    <tr>
    <cfloop query="photocontest" startrow="#StartRow#" endrow="#EndRow#">

    <td valign="top"><cfoutput query="Photocontest"><form method="Post"
    name="photocontest" action="vote.cfm">
    <table width="136" border="0" align="center" cellpadding="2" cellspacing="0"
    bgcolor="##CCCCCC">
    <tr height="110" valign="top">
    <td valign="top" align="center" bgcolor="##E1DCEC" width="136">
    <cffile action="READ" file="Portfolio\images\1\#ImageName#" variable="JPG">
    <CFSET Width="#JPG#">
    <CFSET Height="#JPG#">
    <a
    href="javascript:PopupPic('Portfolio/images/1/#ImageName#?ID=#photocontest.ID#')
    "><img src="Portfolio/images/1/#ImageName#" onLoad="makeFit(this, #width#,
    #height#)" align="center" border="0" alt="Hello"></div></a></td>
    </tr>
    </table>

    murpg Guest

  2. Similar Questions and Discussions

    1. CFFILE ACTION=READ question
      Hey Gang- I have a .cfm page that reads a text file using "cffile action=read" that I parse, read, loop through, etc. When I loop through the...
    2. Action Script to read multiple datasets in XML doc forFlash Bar Chart
      I am trying to compare groups of items using an XML source and need assistance in creating the Action Script to properly read multiple datasets...
    3. CFILE: How Can I restrict Upload File Size?
      I am using CF 5 and would like to restrict the file size when using <CFILE Action="Upload">. Is there an easy way to do this?
    4. CFILE
      Hey there, I had a related question to this. I am using a <input type="file"> in a form for a <cffile> on processing page and I was wondering, is...
    5. CALL TO ACTION: Photoshop GURU's help solve "BULGEGATE"... please read
      CALL TO ACTION: Photoshop GURU's help solve "BULGEGATE"... please read Here is the story, there are 12 pictures of a wirey shape up Bush's back in...
  3. #2

    Default Re: Getting an error with a cfile read action

    It looks like the error message tells you what the problem is:

    The cause of this exception was: java.io.FileNotFoundException:
    Portfolio\images\1\a.jpg (The system cannot find the path specified).

    You should try modifying your CFFILE command to provide a full path name. This
    might take care of it.

    For example:
    cffile action="READ" file="C:\Inetpub\wwwroot\Portfolio\images\1\#Image Name#"
    variable="JPG">

    -Paul

    Paul Dempsey
    Dickinson College



    dempster Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139