Solved

Extracting Uploaded Filename in ColdFusion

Posted on 2014-02-10
2
645 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
ID: 39847681
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
ID: 39847742
File Upload - File NameThat worked. Thank you.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weird Behavior in ColdFusion 8 80
InputBaseN() returns different value in ColdFusion 10 and CF2016 5 108
Coldfusion retrieve dynamic values 1 40
coldfusion cfloop help 6 34
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 …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…

830 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