Solved

Coldfusion rename file and place in another directory

Posted on 2015-01-09
1
145 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

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

18 Experts available now in Live!

Get 1:1 Help Now