Coldfusion.fileUpload.setUrl

Description

Used to set URL for the fileupload control dynamically.

Returns

Nothing

Function syntax

ColdFusion.fileUpload.setUrl(id, url)

Parameters

  • Id: Name of upload control.
  • Url: URL can be an absolute URL, relative URL, or fully qualified URL.

Example

<script language="javascript">
var uploadDone = function(result){
alert("File uploaded");
}

var setUploadUrl = function(id)
{
var selectedFiles = ColdFusion.FileUpload.getSelectedFiles(id);
var uploadUrl = "/manual/ajaxui/cffileupload/setUrl/includes/_uploadall.cfm";
alert("Upload URL : " + uploadUrl);
if(selectedFiles.length){
ColdFusion.FileUpload.setURL(id,uploadUrl);
ColdFusion.FileUpload.startUpload(id);
}
}
var callbackhandler = function(obj)
{
var fileName = obj["FILENAME"];
var status = obj["STATUS"];
var message = obj["MESSAGE"];
var msg = "In callbackhandler()" + "\n\n" +
"FILENAME: " + fileName + "\n\n" +
"STATUS: " + status + "\n\n" +
"MESSAGE: " + message
alert(msg);
}
var errorhandler = function()
{
alert("In errorhandler()");
}
var uploadcompleted = function()
{
alert("All files have been uploaded successfully");
}
</script>
<cfform name="frmUpload">
<br>
<cffileupload name="uploader" hideuploadbutton="true" onComplete="uploadDone" onError="errorhandler" onUploadComplete="uploadcompleted">
<br>
<cfinput type="button" name="submit" value="Click to set URL and Upload Files" onClick="setUploadUrl('uploader')">
</cfform>

Get help faster and easier

New user?