Skip to main content

Posts

Showing posts with the label cffile

How to upload only image file in coldfusion

cffile - upload only image file cffileUploadImge.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>cffile tag: how to upload only image file in coldfusion</title> </head> <body> <h2 style="color:DodgerBlue; font-style:italic">cffile example: Upload Image</h2> <hr width="350" align="left" color="PaleVioletRed" /> <cfset UploadFolder="C:\UploadImage"> <h3 style="color:DeepPink; font-style:italic;"> <cfoutput> <cfif DirectoryExists(UploadFolder)> <cfif IsDefined("Form.UploadFile") AND Form.UploadFile NEQ ""> <cftry> <cffile action="upload" filefield="UploadFile" destination="#Uplo...

ColdFusion: How to upload a file into web server

Introduction File uploads are a common requirement in web applications, allowing users to transfer documents, images, or other files to a web server. ColdFusion provides a straightforward way to implement this functionality using the <cffile> tag, a powerful tool that simplifies file operations like uploading, reading, and writing files on the server. In this tutorial example, we will explore how to create a simple file upload form in ColdFusion using the <cffile> tag. The code demonstrates how to handle the upload process and manage the uploaded files efficiently. This tutorial is designed to help developers understand the key components involved in uploading a file to a server, with a focus on creating a user-friendly form and handling file transfer securely. By the end of this explanation, you will have a clear understanding of how to configure file uploads, define server-side directories, and handle potential issues such as file overwriting. The HTML Form for File Upl...

How to write text to a text file or create new one in coldfusion

cffile - write text to a text file or create new one cffilewrite.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ColdFusion cffile tag example: how to write text to a text file or create new one</title> </head> <body> <h2 style="color:DodgerBlue">ColdFusion cffile tag example: Write, Create</h2> <cfset MyFile="C:\Test6.txt"> <cfoutput> File: #MyFile# <cffile action="write" file="#MyFile#" output="cffile tag example action write."> <br /> Text write in file successfully! </cfoutput> </body> </html> More ColdFusion examples cffile - upload file cfdirectory - create directory programmatically cfdirectory - delete directory programmatically

How to copy a file programmatically in coldfusion

cffile - copy file programmatically cffilecopy.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ColdFusion cffile tag example: how to copy file programmatically</title> </head> <body> <h2 style="color:DodgerBlue">ColdFusion cffile tag example: Copy</h2> <cfset SourceFile="C:\Test.txt"> <cfset Destination="C:\TestFolder\Test.txt"> <cfoutput> <cfif FileExists(SourceFile)> Source File Exists: #SourceFile# <br /> Destination: #Destination# <cffile action="copy" source="#SourceFile#" destination="#Destination#"> <br /> file copy to desination successfully! <cfelse> Source File not Exists: #SourceFile# </cfif> </cfo...

How to append text to a text file on the server in coldfusion

cffile - append text to a text file on the server cffileappend.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ColdFusion cffile tag example: how to append text to a text file on the server</title> </head> <body> <h2 style="color:DodgerBlue">ColdFusion cffile tag example: Append</h2> <cfset MyFile="C:\Test.txt"> <cfoutput> <cfif FileExists(MyFile)> File Exists: #MyFile# <cffile action="append" file="#MyFile#" output="This is a test line."> <br /> Text append in this file successfully! <cfelse> File not Exists: #MyFile# </cfif> </cfoutput> </body> </html> More ColdFusion examples cffile - copy file programmatically ...