There are two forms present on a single page. An upload script has been implemented (source unknown) and it functions correctly. However, the script is triggered when either of the forms is submitted. The objective is to determine which form was submitted and execute different actions for the second form. Both forms require the complete function.
<form action="upload.php" name="upform" method="post" enctype="multipart/form-data" onsubmit="return disuload();">
<label for="ftp_upload" id="uloadlfile">Select a file: </label><input type="file" name="ftp_upload" id="uloadfile"></br>
<label for="ftp_upcomm" id="uloadlcomm" class="percent">Comments: </label><input type="text" name="ftp_upcomm" size="34" id="uloadcomm"></br>
<label id="uloadlimit">Maximum upload size: <?php echo ini_get('post_max_size'); ?></label></br>
<input type="submit" id="uloadsub" value="Upload">
</form>
FORM2
<form method="post" name="NewFolder">
<label for="ftp_nfolder">Folder name: </label><input type="text" name="ftp_nfolder" size="30"></br>
<input type="submit" value="Create">
</form>
SCRIPT
(function() {
var bar = $('.bar');
var percent = $('.percent');
$('form').ajaxForm({
beforeSend: function() {
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal + ' uploaded, Please wait...');
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal + ' uploaded, Please wait... ');
},
complete: function(xhr) {
bar.width("0%");
location.reload();
percent.html(xhr.responseText);
}
});
})();