Skip to main content
Inspiring
March 15, 2012
Answered

Import image file

  • March 15, 2012
  • 2 replies
  • 742 views

Hi,

I am using a cfm page to import an image file.

<cfset setEncoding("url","utf-8")>

<cfset setEncoding("form","utf-8")>

<cfif IsDefined("Form.fileData") and IsDefined("Form.fileName")>

<cffile action="upload"

      fileField="Filedata"

      nameconflict="overwrite"

      destination="#application.upload_folder#"

      mode="666"

      result="ret">

</cfif>

It is a way to check for duplicate image file names in the folder?

How can I resize the image to a particular width and height?

Thanks!

    This topic has been closed for replies.
    Correct answer jfb00

    <cfif IsDefined("Form.fileData") and IsDefined("Form.fileName")>

      <cfimage source="#Filedata#" action="resize" width="50%" height="50%" destination="c:\temp\#fileName#" overwrite="no">

    </cfif>

    If i set overwrite=NO i got an Error #2038: File I/O Error. URL:

    When I debug this error CF return Specify a new destination file or specify overwrite = "true".

    I assumed that it is a duplicate, correct?

    Maybe this help someone else later.

    Best,

    2 replies

    jfb00AuthorCorrect answer
    Inspiring
    March 15, 2012

    <cfif IsDefined("Form.fileData") and IsDefined("Form.fileName")>

      <cfimage source="#Filedata#" action="resize" width="50%" height="50%" destination="c:\temp\#fileName#" overwrite="no">

    </cfif>

    If i set overwrite=NO i got an Error #2038: File I/O Error. URL:

    When I debug this error CF return Specify a new destination file or specify overwrite = "true".

    I assumed that it is a duplicate, correct?

    Maybe this help someone else later.

    Best,

    jfb00Author
    Inspiring
    March 15, 2012