我一直在为plUpload工作一个页面,以便与ColdFusion一起工作,看看在这里实现我的ColdFusion系统是多么可行......一旦我确定它有效,我就会这样做。我计划使用JS脚本和CSS的本地副本。到目前为止,前端看起来很棒,但是我无法确定为什么ColdFusion上传页面upload_files.cfm
没有被调用...我已经在一些CFMAIL标签中引入了ColdFusion页面为了确保我能够正常运行而被召唤......但是没有电子邮件到达......如果有人可以指出它是什么我在这里做错了,我会喜欢它。
我将主要前端基于HTML页面,名为custom.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Plupload - Custom example</title>
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/css/bootstrap.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/css/font-awesome.min.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/css/my.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/css/prettify.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/css/shCore.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/css/shCoreEclipse.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://www.plupload.com/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css" media="screen" />
<!-- production -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" charset="UTF-8"></script>
<script type="text/javascript" src="../js/plupload.full.min.js"></script>
</head>
<body style="font: 13px Verdana; background: #eee; color: #333">
<h1>Custom example</h1>
<p>Shows you how to use the core plupload API.</p>
<div id="uploader">
<p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
</div>
<script type="text/javascript">
// Initialize the widget when the DOM is ready
$(function() {
$("#uploader").plupload({
// General settings
runtimes : 'html5,html4',
url : "upload_files.cfm",
// Maximum file size
max_file_size : '2mb',
chunk_size: '1mb',
// Resize images on clientside if we can
resize : {
width : 200,
height : 200,
quality : 90,
crop: true // crop to exact dimensions
},
// Specify what files to browse for
filters : [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip,avi"}
],
// Rename files by clicking on their titles
rename: true,
// Sort files
sortable: true,
// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,
// Views to activate
views: {
list: true,
thumbs: true, // Show thumbs
active: 'thumbs'
},
// Flash settings
flash_swf_url : '/plupload/js/Moxie.swf',
// Silverlight settings
silverlight_xap_url : '/plupload/js/Moxie.xap'
});
});
</script>
<script type="text/javascript" src="http://www.plupload.com/js/bootstrap.js" charset="UTF-8"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="http://www.plupload.com/plupload/js/plupload.full.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="http://www.plupload.com/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="http://www.plupload.com/js/themeswitcher.js" charset="UTF-8"></script>
</body>
</html>
upload_files.cfm,被调用的URL,代码如下:
<!---
The Name field represents the filename as it exists on the client
machine.
--->
<!--- I've added the CFMAIL below as debug, so far, no emails come through... --->
<cfmail from="err@lymlive.com.au" to="eliseo.dannunzio@lymlive.com.au" subject="Test" type="html">
foo bar
</cfmail>
<cfparam name="form.name" type="string" />
<!---
The File field represents the TMP file into which the binary
data of the upload is being stored. This can be accessed via
CFFile/Upload.
--->
<cfparam name="form.file" type="string" />
<!--- Sleep for a brief period to allow UI a chance to show. --->
<!--- ------------------------------------------------------ --->
<cfset sleep( 1000 ) />
<!--- ------------------------------------------------------ --->
<!--- Save the file to the uploads directory. --->
<cffile
result="upload"
action="upload"
filefield="file"
destination="#application.uploadsDirectory#"
nameconflict="makeunique"
/>
<!--- Return a success message. --->
<cfheader
statuscode="201"
statustext="Created"
/>
引导application.uploadsDirectory
的Application.cfc如下:
<cfscript>
component
output = "false"
hint = "I define the application settings and event handlers."
{
// Define the application settings.
this.name = hash( getCurrentTemplatePath() );
this.applicationTimeout = createTimeSpan( 0, 0, 10, 0 );
this.sessionManagement = false;
// I initialize the application.
function onApplicationStart(){
// Get the root directory of the demo.
var rootDirectory = getDirectoryFromPath( getCurrentTemplatePath() );
// Set up the uploads directory.
application.uploadsDirectory = (rootDirectory & "uploads/");
// Return true so the application can load.
return( true );
}
// I initialize the request.
function onRequestStart(){
// Check to see if we need to manually reset the application.
if (structKeyExists( url, "init" )){
this.onApplicationStart();
}
// Return true so the page can load.
return( true );
}
}
</cfscript>
答案 0 :(得分:0)
我确保在form.name
的{{1}} cfparam
标记中设置了默认文件名,并将uploadfiles.cfm
文件重写为一个标准Application.cfc
版本,而不是我之前的cfcomponent
版本......
cfscript
标签中的output = false
语句似乎失败了......但我无法从plUpload例程中确定...
感谢您的提醒!