Solved

parse out image and extension using railo (coldfusion)

Posted on 2010-09-01
8
316 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 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

19 Experts available now in Live!

Get 1:1 Help Now