?
Solved

parse out image and extension using railo (coldfusion)

Posted on 2010-09-01
8
Medium Priority
?
322 Views
Last Modified: 2013-12-24
I'm using type="file" in the form, but when i submit the form, the page that follows I get this..

/var/www/domain/public_html/WEB-INF/railo/temp/tmp-20

using..

<cfset thisimage = listfirst(#form.imagefile#,".")>

<cfoutput>#thisimage#</cfoutput>

how would I parse out the name of the file and its extension?
0
Comment
Question by:COwebmaster
  • 4
  • 2
  • 2
8 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 33583675
Again, just a guess ... but I'd imagine Railo is like the Adobe version.  All files are uploaded to a temp server directory first and given a temporary file name.  That's what you're seeing when you look at #form.imagefile#.  

You then have to use cffile "upload" to get access to the real file name (and move it to desired directory). Use CFFILE variables like #CFFILE.serverFile#, #CFFILE.serverDirectory# to access the file name and extension ...

ie <cffile action="upload" filefield="form.imagefile" .....>
<cfdump var="#CFFILE#">
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33583757
To clarify the last comment.  First upload.

      <cffile action="upload" filefield="form.imagefile" .....>
 
Then use the cffile variables:

    #CFFILE.serverFileExt#
    Extension of the uploaded file on the server (without a period)

   #CFFILE.serverFileName#
   Name of the uploaded file on the server (without an extension)


0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33584898
You can use

#cffile.serverfile#

you will get complete file name along with its extension.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

Expert Comment

by:_agx_
ID: 33584952
They want the name and extension separated.  Fortunately, cffile has variables for that too ;-) See my previous post.
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33587865
Hi, if you want the original file name (name of the file, as you select before uploading), you can use

#cffile.clientfile# ==> complete file name with extension
#cffile.clientfileName# ==> File name (as it was in your system before uploading) without extension
#cffile.clientfileExt# ==> file extension
0
 

Author Comment

by:COwebmaster
ID: 33588609
ok, I'll try out your suggestions.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 33589210
Personally, I've never found use for client variables.  99% of the time what you're looking for is information about files on your *server*.  That can only be obtained from the *server* variables I mentioned earlier:

    #CFFILE.serverFileExt#
   #CFFILE.serverFileName#

Based on the original question,  you almost certainly should NOT be using the client variables.


0
 

Author Closing Comment

by:COwebmaster
ID: 33592823
Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
What You Need to Know when Searching for a Webhost Provider
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

840 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