?
Solved

Coldfusion rename file and place in another directory

Posted on 2015-01-09
1
Medium Priority
?
160 Views
Last Modified: 2015-01-10
I need the path name in order to rename a file. The user selects the file to be renamed and ColdFusion should rename the file.

My challenge is how to get the pathname of the selected file.


<!--- Check to see if the Form variable exists. --->
<cfif isDefined("Form.FileContents") >


<!---
<cffile
action = "rename"
    destination = "pathname"
    source = "full pathname"
    attributes = "file attributes list"
    mode = "mode"> --->a
<cfelse>
    <!--- If FALSE, show the Form. --->
    <form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>
        name="uploadForm" enctype="multipart/form-data">
        <input name="FileContents" type="file">
        <br>
        <input name="submit" type="submit" value="Upload File">
    </form>
</cfif>
0
Comment
Question by:Errol Farro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 40541651
(Not sure I follow what you're ultimately trying to do, but ...)

>> I need the path name in order to rename a file.

Which path are you referring to?

A) The original location of the file on the user's computer before they upload it, ie:
      C:\Users\Bob\PhotosFromCompanyRetreat.zip
 
-OR-

B) The path on the server after it's uploaded? ie:
     c:\yourApp\uploadedFiles\PhotosFromCompanyRetreat.zip

If you mean A) you can't.  Browsers are not allowed to send information about paths on the client machine due to security restrictions.  IIRC some versions of IE might, but that's a fluke.

If you mean B) - after the form is submitted use <cffile action="upload" ...> . You can specify whatever directory you want. The upload action will populate a structure named CFFILE. It'll contain details about the file, including it's location on the server. You can use these variables to obtain the final name and location of the file on the server:

          #CFFILE.serverFile#          <!--- file name and extension
          #CFFILE.serverDirectory#  <--- folder location

If that's not what you mean, can you provide more details? If you explain the overall objective (without code) we may be able to suggest other options.
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

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