<form name="PowUploadForm" enctype="multipart/form-data" method="post" action=""> <input name="selectedFile" id="selectedFile" type="file" /> <input name="uploadFile" type="submit" id="uploadFile" value="Process Actions"/> </form>
Then a block of jquery/ajax that triggers via .click function:
$(document).ready(function(){
$("##uploadFile").click( function() {
if(document.PowUploadForm.selectedFile.value==""){
$('##error').show();//shows a div with an error message in it
return false;
}else{
var usrFile = $("##selectedFile").val();
var param = {powFile:usrFile};
$.ajax({
type: "POST",
url: "new_rename_save_pow.cfm",
dataType: "text",
data: param,
error: function() {
alert('Ajax Error');
},
success: function(response){
$("##uploadSuccess").html(response);
}
});
}
});
});
Then I have .cfm page with the upload logic:
<cfset protectedPath = "/usr/local/pow_upload/"> <cffile action="upload" fileField =" " destination="#protectedPath#" nameconflict="makeUnique" mode="644" /> <!---This next bit of html will be returned and displayed in the 'uploadSuccess' div---> <h3>Thank You!</h3> <p>File Uploaded successfully</p>
As you may notice the fileField attribute of the cffile tag is empty because I am not sure what goes in there. I've tried a variety of things: #File.ServerFile#, selectedFile, powFile, usrFile, param, etc. nothing is working. I do not get any errors but nothing is returned to my target div ('uploadSuccess'), and the chosen file is not uploaded. Any tips will be greatly appreciated. Thanks!

New Topic/Question
Reply
MultiQuote








|