Solved

parse out image and extension using railo (coldfusion)

Posted on 2010-09-01
8
317 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
coldfusion upload spreadsheet into the databse 2 44
Only three borders showing on image 5 19
MouseOver help for Intranet website 2 23
Javascript_Set_dropdown_value 7 32
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Find out what you should include to make the best professional email signature for your organization.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

770 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