Solved

Coldfusion rename file and place in another directory

Posted on 2015-01-09
1
147 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
1 Comment
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion HTTPS 2 63
expandPath erroring 15 57
paging 3 37
Coldfusion - rename files in a folder 4 8
This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

18 Experts available now in Live!

Get 1:1 Help Now