Solved

Extracting Uploaded Filename in ColdFusion

Posted on 2014-02-10
2
633 Views
Last Modified: 2014-02-10
Upload 1Upload 2
I am uploading a photo file from my C drive to the ISP webserver and like to know how to extract the file name after it is uploaded. As seen in the screenshots, I can capture the data (entered in Upload_photo1.cfm) in Upload_photo2.cfm except the photo file name.
I tried to display the contents of "file_path", but that resulted in "C:\ColdFusion10\cfusion\runtime\work\Catalina\localhost\tmp\neotmp4276945136024192972.tmp "

Upload_photo1.CFM
--------------------------------------------------
          <CFform action="upload_photo2.cfm" method="POST" name="frmupload" enctype="multipart/form-data">
            <CFINPUT type="file" name="file_path">
--------------------------------------------------

Upload_photo2.CFM
--------------------------------------------------
            <cfif isdefined("form.submit_upload")>
                  <cffile action="UPLOAD" filefield="file_path" destination="D:\home\ABC.com\wwwroot\imageupload\single" nameconflict="MAKEUNIQUE">
                        <font color=blue><h3>File Uploaded Successfully!</h3></font>
            </cfif>
--------------------------------------------------
0
Comment
Question by:sglee
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 320 total points
Comment Utility
but that resulted in "C:\ColdFusion10\cfusion\runtime\work\Catalina\localhost\tmp\neotmp4276945136024192972.tmp "

When CF receives the upload it stores it in a temp file. That's what you're seeing.

After you use <cffile action="upload" ...>, CF populates the CFFILE structure with info about the uploaded file. To get the saved file name ie "jellyFish.jpg", use:

*Note: Because you're using "makeUnique" it may be slightly different, like "jellyFish (2).jpg"....

      <cffile action="UPLOAD" ....>
      <cfoutput>saved file name : #CFFILE.serverFile#</cfoutput>

To see all variables available
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-738f.html
0
 

Author Comment

by:sglee
Comment Utility
File Upload - File NameThat worked. Thank you.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

12 Experts available now in Live!

Get 1:1 Help Now