EasyCFM.COM ColdFusion Forums / Good Coding Tips! / Uploading Images or Files

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Uploading Images or Files

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

Frosty
07-15-2009 @ 9:12 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 18
Joined: Jun 2009

HEllo Coldfusion-ers!

I would like enable a file upload in my coldfusion application (.doc, .xls, .pdf or .jpeg)

Would anybody be able to direct me to a sample code, tutorial or website where I might be able to learn/find the coding to create an upload function?

Frosty the ColdFusion snowman

Lyndon
09-23-2009 @ 11:17 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 66
Joined: Jun 2004

Form Template:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
     <title>IDALS File Upload</title>
</head>

<body>
<div align="center">IDALS File Upload Utility</div>
<form name="PutFile" action="SaveIDALSFile.cfm" method="post" enctype="multipart/form-data">
     File to Upload:
     <input size="50" maxlength="300" type="File" name="UpFile">
     <input name="UpFileBtn" type="Submit" value="Upload">
</form>
<br>
<span style="color:red; font-size: 20px; ">
Note: Uploads of same name will be overwritten</span><br> If there is a problem with your upload, such as incorrect file size, send it agian to replace it.

Action Template:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
     <title>Upload</title>
</head>

<body>
<cfset IDALSDirectory=GetDirectoryFromPath(ExpandPath("*.*"))&"IDALS\">
<CFFILE ACTION="UPLOAD" destination="#IowaDirectory#" NAMECONFLICT="OVERWRITE" FILEFIELD="FORM.UpFile">
<cfdirectory action="LIST" name="IDALSFiles" directory="C:\Inetpub\wwwroot\IDALS" />
<table border="1" align="center">
     <tr>
          <td>File Name</td>
          <td><div align="right">File Size</div></td>
          <td>File Date</td>
     </tr>
          <cfoutput query="IDALSFiles">
               <cfif Trim(IowaFiles.Name) neq '.' and Trim(IDALSFiles.Name) neq '..'>
                    <tr>
                         <td>#IDALSFiles.Name#</td>
                         <td><div align="right">#NumberFormat(IDALSFiles.size)#</div></td>
                         <td>#DateFormat(IDALSFiles.dateLastModified,'mm/dd/yyyy')#</td>
                    </tr>
               </cfif>
          </cfoutput>
</table>
<br>
<a href="IDALS.cfm">Return to Upload Page</a>

</body>
</html>



Lyndon

Cfdevshop
03-17-2013 @ 10:57 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Member
Posts:
Joined: Mar 2013

<cffile  > is used to upload a file in server, its easy and compact. we also have <cfftp> tag for
same reason.
<cffile action="Upload"
                                fileField="fieldName"
                                destination="#destinationPath#"
                                nameConflict="Overwrite"
                                accept="image/jpeg, image/gif, image/png">
                          

Coldfusiondevshop


Website Designed and Developed by Pablo Varando.