Highlighted

get cffile name

New Here ,
Jul 06, 2015

Copy link to clipboard

Copied

Aloha All,

Thank you for any help in advance.  I am attempting to insert the image name into a database so I can recall it later.

This is my code for uploading the photo.

<cfif isDefined("form.image") >

    <cffile action = "upload"

        fileField = "image"

        destination = "D:\home\manpcs.com\wwwroot\Realtor\images\"

        accept = "image/jpeg"

        nameConflict = "MakeUnique">

        Done uploading image!

       <cfoutput> #form.image#</cfoutput>

<cfelse>

    <cfform method="post" action="test.cfm"

        name="uploadForm" enctype="multipart/form-data">

        <cfinput name="image" type="file">

        <br><br>

        <cfinput name="submit" type="submit" value="Upload image">

    </cfform>

</cfif>

When I output the form.image I receive th following.

Done uploading image! 1 2 C:\ColdFusion11\cfusion\runtime\work\Catalina\localhost\tmp\neotmp5787371421837803116.tmp4

In the images file I get the image names as "example.jpg,

I want to capture the real image name.  How can I?

Views

329

Likes

Translate

Translate

Report

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

get cffile name

New Here ,
Jul 06, 2015

Copy link to clipboard

Copied

Aloha All,

Thank you for any help in advance.  I am attempting to insert the image name into a database so I can recall it later.

This is my code for uploading the photo.

<cfif isDefined("form.image") >

    <cffile action = "upload"

        fileField = "image"

        destination = "D:\home\manpcs.com\wwwroot\Realtor\images\"

        accept = "image/jpeg"

        nameConflict = "MakeUnique">

        Done uploading image!

       <cfoutput> #form.image#</cfoutput>

<cfelse>

    <cfform method="post" action="test.cfm"

        name="uploadForm" enctype="multipart/form-data">

        <cfinput name="image" type="file">

        <br><br>

        <cfinput name="submit" type="submit" value="Upload image">

    </cfform>

</cfif>

When I output the form.image I receive th following.

Done uploading image! 1 2 C:\ColdFusion11\cfusion\runtime\work\Catalina\localhost\tmp\neotmp5787371421837803116.tmp4

In the images file I get the image names as "example.jpg,

I want to capture the real image name.  How can I?

Views

330

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 06, 2015 0
Advocate ,
Jul 07, 2015

Copy link to clipboard

Copied

After outputting #form.image#, do the same for #cffile# and I believe you will see what you are looking for.

Cheers

Eddie

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2015 0
BKBK LATEST
Adobe Community Professional ,
Jul 07, 2015

Copy link to clipboard

Copied

When you upload, the form scope actually becomes irrelevant. Coldfusion creates the cffile structure and stores the uploaded file's properties in it. So, what you want is

  <cfoutput>#cffile.clientFile#</cfoutput>

In fact, if you add the following test code, you will be much the wiser.

<cfdump var="#form#" label="form">

<cfdump var="#cffile#" label="cffile">

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2015 0