Coldfusion - cannot access templ folder when creating thumb - coldfusion

I am getting a problem with the following line:
<cfimage action="read" name="myImage" source="#ExpandPath("../../banner/#upload.clientfile#")#" />
I suspect it is because I am using a shared host (CF9) and do not have access to the folder. The error I get is "unable to create temporary file". My temp directory is home/kloxo/temp/wwwroot-tmp. Can I specify another temp folder or do I have to get my hosting company to sort this?
<cfapplication sessionmanagement="true">
<cfoutput>#GetTempDirectory()#</cfoutput>
<cfif IsDefined ("FORM")>
<cfif structKeyExists(form, "uploadfile")>
<cfset destination = expandPath("../../banner")>
<cfif not directoryExists(destination)>
<cfdirectory action="create" directory="#destination#">
</cfif>
<cffile action="upload" filefield="uploadfile" destination="#destination#" nameConflict="makeUnique" result="upload">
<cfdump var="#upload.clientfile#">
<cfimage action="read" name="myImage" source="#ExpandPath("../../banner/#upload.clientfile#")#" />
</cfif>

It appears to be a configuration issue. Contact your host. Here is a page with more information:
http://forums.adobe.com/message/3060530

Related

Custom CFInclude for file customization

Our code base has quite a bit of the following example as we allow a lot of our base pages to be customized to our customers' individual needs.
<cfif fileExists("/custom/someFile.cfm")>
<cfinclude template="/custom/someFile.cfm" />
<cfelse>
<cfinclude template="someFile.cfm" />
</cfif>
I wanted to create a custom CF tag to boilerplate this as a simple <cf_custominclude template="someFile.cfm" />, however I ran into the fact that custom tags are effectively blackboxes, so they aren't pulling in local variables that exist prior to the start of the tag, and I can't reference any variable that was created as a result of the tag from importing the file.
E.G.
<!--- This is able to use someVar --->
<!--- Pulls in some variable named "steve" --->
<cfinclude template="someFile.cfm" />
<cfdump var="#steve#" /> <!--- This is valid, however... --->
<!--- someVar is undefined for this --->
<!--- Pulls in steve2 --->
<cf_custominclude template="someFile.cfm" />
<cfdump var="#steve2#" /> <!--- This isn't valid as steve2 is undefined. --->
Is there a means around this, or should I utilize some other language feature to accomplish my goal?
Well, I question doing this at all but I know we all get handed code at times we have to deal with and the struggle it is to get people to refactor.
This should do what you are wanting. One important thing to note is that you will need to ensure your custom tag has a closing or it won't work! Just use the simplified closing, so like you had it above:
<cf_custominclude template="someFile.cfm" />
This should do the trick, called it has you had it : custominclude.cfm
<!--- executes at start of tag --->
<cfif thisTag.executionMode eq 'Start'>
<!--- store a list of keys we don't want to copy, prior to including template --->
<cfset thisTag.currentKeys = structKeyList(variables)>
<!--- control var to see if we even should bother copying scopes --->
<cfset thisTag.includedTemplate = false>
<!--- standard include here --->
<cfif fileExists(expandPath(attributes.template))>
<cfinclude template="#attributes.template#">
<!--- set control var / flag to copy scopes at close of tag --->
<cfset thisTag.includedTemplate = true>
</cfif>
</cfif>
<!--- executes at closing of tag --->
<cfif thisTag.executionMode eq 'End'>
<!--- if control var / flag set to copy scopes --->
<cfif thisTag.includedTemplate>
<!--- only copy vars created in the included page --->
<cfloop list="#structKeyList(variables)#" index="var">
<cfif not listFindNoCase(thisTag.currentKeys, var)>
<!--- copy from include into caller scope --->
<cfset caller[var] = variables[var]>
</cfif>
</cfloop>
</cfif>
</cfif>
I tested it and it works fine, should work fine being nested as well. Good luck!
<!--- Pulls in steve2 var from include --->
<cf_custominclude template="someFile.cfm" />
<cfdump var="#steve2#" /> <!--- works! --->

ColdFusion HELP Pages not Updating: My CF pages are still pointing to the original folder of my application

I have an existing ColdFusion application in my server. What I needed is a duplicate of that application. What I did was copy the entire folder of the original application and put it into another folder.
I already edited the Application.cfm and the links across all the pages in my copy. However, .../indexc.cfm?page=a_app_checklist - in this case, the a_app_checklist is not being updated even if I changed everything on my server /Copy/pages/app/a_app_checklist.cfm
I tried to upload the updated a_app_checklist.cfm on the original application and from there, it was updated. What should I do because I want my copy of the application to be a stand-alone from the original application.
Here is a part of my Application.cfm code:
<cfapplication name="Applicationv2" sessionmanagement="yes" setclientcookies="yes" sessiontimeout="#CreateTimeSpan(00,00,30,00)#"
applicationtimeout="#CreateTimeSpan(00,01,00,00)#" clientstorage="cookie" loginstorage="session">
<cfparam name="Url.page" default="a_main_index">
<cfparam name="Url.formpage" default="">
<cfparam name="Url.resetAppCache" default="">
<!--- Set the Application variables if they aren't defined. --->
<cfset app_is_initialized = False>
<cflock scope="application" type="readonly" timeout="5">
<cfset app_is_initialized = IsDefined("Application.initialized")>
</cflock>
<cfif not app_is_initialized>
<cflock scope="application" type="exclusive" timeout=10>
<cfif not IsDefined("Application.initialized")>
<!--- Do initializations --->
<cfset Application.StudentDB = "DB">
<cfset Application.Url = "/CopyOfApplication/">
<cfset Application.NSUrl = "/CopyOfApplication/">
<cfset Application.EmailLocation = "/CopyOfApplication/pages/email/">
<cfset Application.userfilespath = "/web_assets/UserFiles/">
<cfset Application.UnauthorizedFileExtentions = "ade,adp,asx,bas,chm,cmd,cpl,crt,dbx,exe,hlp,com,hta,inf,ins,isp,jse,lnk,mda,mde,mdz,mht,msc,msi,msp,mst,nch,pcd,prf,reg,scf,scr,sct,shb,shs,url,tmp,pif,dll,vb,vbs">
<cfset Application.ReportPage = "report.cfm">
<cfset Application.PrintPage = "print.cfm">
<!---Puts an instance of the user.cfc and system.cfc in the application scope. All pages can use it. --->
<cfobject type="component" name="Application.System" component="application.system">
<cfset Application.initialized = "yes">
</cfif>
</cflock>
<cfscript>
Application.System.LogActivity("Name","IP","Application scope variables initialized.");
</cfscript>
</cfif>
Like I said, the "page" part in the URL are the only ones that are not being updated. Does it mean I have problems with my URL.Page initialization?
Please let me know if you need additional code. I appreciate any input about this question. Thank you in advance! I am still learning ColdFusion and I will appreciate it if you will help me understand what I need to know!

how can i copy folders, subfolders and their files?

I have one folder called misc which contains few sub folders and each sub folders has sub sub folders and files in it and I want to copy the sub folders, sub sub folders and its files in a called default folder.
I have tried this getting empty folder. And also I am wondering why Coldfusion doesn't have copy attribute in cfdirectory tag.
<cfset CurrentDirectory=GetTemplatePath()>
<cfset CurrentDirectory=ListDeleteAt(CurrentDirectory,ListLen(CurrentDirectory,"/\"),"/\")>
<cfset NewDirectory="#CurrentDirectory#\default">
<cfif NOT directoryExists(NewDirectory)>
<cfdirectory action="create" directory="#NewDirectory#">
</cfif>
<cfset strPath = ExpandPath("c:/wwwroot/test/misc") />
<cfdirectory action="list" directory="#strPath#" name="exDir">
<cfif exDir.type EQ 'File' >
<cffile action="copy" source="#strPath#" destination="#NewDirectory#" mode="777">
</cfif>
<cfif exDir.type EQ 'Dir'>
<cfdirectory action="create" directory="#NewDirectory#" mode="777">
</cfif>
<cfdump var = "#strPath#">
<cfdump var="#exDir#">
can anyone please let me know why I am getting empty folder ? any help would be appreciated!
directoryCopy() on cflib should do the job, or use cfzip

How to access the object created by a cffile upload in coldfusion

I have an assortment of issues, but I'm going to concentrate on one here. How to I access the object created from a cffile upload. I am currently doing as so.
<cffile action="upload" destination="#Application.filePath#Pics/" filefield="image1" nameconflict="makeunique">
<cfif isDefined ("cffile.serverFile")>
<cfset image1Place = #cffile.serverFile#>
</cfif>
but that doesn't seem like it would work well with multiple file uploads, which happens to be my case.
If you're worried about the result object being blown away as a consequence of multiple invocations of cffile, then you can use the "result" attribute to distinguish them:
<cfset uploadResults = {}>
<cfloop list="#form.filelist#" index="myFile">
<cffile action="upload" destination="#Application.filePath#Pics/"
filefield="#myFile#" nameconflict="makeunique"
result='uploadResults.#myFile#'>
<cfif StructKeyExists(uploadResults, myFile)>
<cfset image1Place = uploadResults[myFile].serverFile>
</cfif>
</cfloop>

ColdFusion MX 7.0 Flash based multiple file uploader causing issues after 2/3 files upload

I have an application that uses a single signon for login in ColdFusion MX 7.0. It essentially
has a cfldap in the application.cfm. But the real issue is that I am trying to use a multi-file upload third party tool that submits to a coldfusion script with cffile and stuff in it.
Both the Flash based tool and the Java based tool are cauing an issue when I try a uploading more than 3 files at the same time. First they prompt the windows based login again. Even though I type in the credentials correctly, the upload process stops completely and only 1/2
files are uploaded.
The code for the Interface(form) for multi_file upload
<body>
<div id="EAFlashUpload_placeholder"></div>
<cfparam name="session.multiUploadError" default="">
<cfif session.multiUploadError neq "">
<font color="#FF0000"><em> <strong>Error Uploading File: </strong>
<cfoutput>#session.multiUploadError#</cfoutput></em></font>
<!--- ok. now wipe the error message clean for next time --->
<cfset session.multiUploadError = "">
</cfif><p></p>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var params = {
wmode: "window"
};
var attributes = {
id: "EAFlashUpload",
name: "EAFlashUpload"
};
var flashvars = new Object();
flashvars["uploader.uploadUrl"] = "http://iapreview.ars.usda.gov/admin/sp2.5/MultiFileUpload.cfm";
flashvars["viewFile"] = "TableView.swf";
flashvars["queue.filesCountLimit"] = "30";
flashvars["uploader.retrieveBrowserCookie"] = true;
swfobject.embedSWF("EAFUpload.swf", "EAFlashUpload_placeholder", "450", "350", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
</script>
</body>
The code for the backend ColdFusion script
<cftry>
<cfif isDefined("Form.Filedata")>
<cffile action="UPLOAD" filefield="Filedata" destination="#session.siteDirectory#\#session.Directory#" nameconflict="OVERWRITE">
<cfif right(cffile.clientFile, 3) neq "htm" and right(cffile.clientFile,4) neq ".htm">
<cfelse>
<cffile action="delete" file="#session.siteDirectory#\#session.Directory#\#cffile.clientFile#">
<cfset session.multiUploadError = " " & session.multiUploadError & " #cffile.clientFile# could not be uploaded, because html files are not permitted.<br> ">
</cfif>
<!---
<cffile action="APPEND" file="f:\sitepublisher_dev\sp2\juploadoutput.txt" output="#idx# - #session.siteDirectory#\#session.Directory#\#cffile.clientFile# (#cffile.fileSize#) at #cffile.timeLastModified#" addnewline="Yes">
--->
</cfif>
The file has not been saved. Please check destination folder exists and has read/write permissions.
<cftry>
<cfif isDefined("Form.Filedata")>
<cffile action="UPLOAD" filefield="Filedata" destination="#session.siteDirectory#\#session.Directory#" nameconflict="OVERWRITE">
<cfif right(cffile.clientFile, 3) neq "htm" and right(cffile.clientFile,4) neq ".htm">
<cfelse>
<cffile action="delete" file="#session.siteDirectory#\#session.Directory#\#cffile.clientFile#">
<cfset session.multiUploadError = " " & session.multiUploadError & " #cffile.clientFile# could not be uploaded, because html files are not permitted.<br> ">
</cfif>
<!---
<cffile action="APPEND" file="f:\sitepublisher_dev\sp2\juploadoutput.txt" output="#idx# - #session.siteDirectory#\#session.Directory#\#cffile.clientFile# (#cffile.fileSize#) at #cffile.timeLastModified#" addnewline="Yes">
--->
</cfif>
<cfcatch type="Any">
<cfoutput><eaferror>The file has not been saved. Please check destination folder exists and has read/write permissions.</eaferror></cfoutput>
</cfcatch>