File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/admin/templates/form.fileupload.tpl
<script type="text/javascript"><!--
$(function(){
// disable other added fields if the file upload field is disabled
if ($('#{$FieldName}').attr('disabled')) {
$('#{$FieldName}_clearselection, #{$FieldName}_addandupload').attr('disabled', true);
}
});
function iwp_form_field_fileupload_clearFileSelection (fieldName) {
$('#'+ fieldName).val('');
}
{if $file_Message}
$(function() {
$('#file_Message').show().infoMessage("Current picture: [<a class='fileMsg' href='index.php?section={$section}&action=deletefile&id={$fileid}'>{$lang.Delete}</a>]<br /><br /><img src='{$file_Message}' />", false);
delClick();
});
{/if}
var currentUploadFileId = '{$fileid}';
function delClick() {
$('.fileMsg').click(function() {
$.ajax({
url: 'remote.php?section={$section}&action=deletefile&id=' + currentUploadFileId,
dataType: 'xml',
success: function(xml, status) {
if($('status', xml).text() == "failure") {
$('#file_Error').errorMessage($('message', xml).text());
} else {
$('#file_Error').hide();
$('#file_Message').successMessage('{$lang.DeletedSuccessfully}');
}
},
error: function(xml, status) {
$('#file_Error').errorMessage('Error: ' + $('status', xml).text());
}
});
return false;
});
}
{if $fileupload.ajax}
function ajaxFileUpload() {
if($('#{$FieldName}').val() == ""){
return false;
}
var tId = '';
{if strlen($fileid) > 0 && $fileid > 0}
tId = '&fileid={$fileid}';
{/if}
$.ajaxFileUpload({
url: 'remote.php?section={$section}&action=fileupload' + tId,
secureuri: false,
fileElementId: '{$FieldName}',
dataType: 'xml',
beforeSend: function () {
var name = $('#{$FieldName}').val().replace(/\\/g, '/');
name = name.split('/');
var pos = name.length;
var fileName = name[pos-1];
var idfileName = fileName.replace(/[^a-zA-Z0-9]/g, '');
$('#uploadingItem').show();
$('#uploadingItem').append('<li id="uploading_file" ><img src="images/load.gif"> Please Wait Uploading '+fileName+'...</li>');
},
success: function (xml, status) {
var name = $('file', xml).text().replace(/[^a-zA-Z0-9]/g, '');
if($('status', xml).text() == "success") {
$('#uploadingItem').hide();
$('#file_Message').show().successMessage('The file "'+$('file', xml).text()+'" has been uploaded.');
$('#file_name').val($('tmpName', xml).text());
$('#{$FieldName}').val('');
if($('showInfo', xml).text() == "true") {
window.setTimeout(function() {
$('#file_Message').fadeIn('slow').infoMessage("Current Picture: [<a class='fileMsg' href='index.php?section={$section}&action=deletefile&id=" + $('fileID', xml).text() + "'>{$lang.Delete}</a>]<br /><br /><img src='" + $('fileURL', xml).text() + "' />");
delClick();
}, 3000);
}
} else if($('error', xml).text() == "nofiles") {
$('#uploading_'+$('unique', xml).text()+'_'+name).remove();
} else {
$('#uploadingItem').hide();
$('#file_Message').show().errorMessage('This file "'+$('file', xml).text()+'" was uploaded unsuccessfully.');
}
},
error: function (data, status, e) {
alert('Error ' + $('status', xml).text());
alert(e);
}
});
return false;
}
{/if}
//--></script>
<tr id="{$FieldName}_row">
<td class="FieldLabel">
<input type="hidden" name="file_name" id="file_name" value="" />
{if $showName}
{if $required}
<span style="color:red;">*</span>
{else}
<span class="AsteriskPlaceholder"> </span>
{/if} {$Name}{if right($Name, 1) != '?'}:{/if}
{/if}
</td>
<td>
<ul id="uploadingItem" class="arrowList">
</ul>
<div id="file_Error" style="display: none; padding: 0px; margin: 0px;"></div>
<div id="file_Message" style="display: none; padding: 0px; margin: 0px;"></div>
<div id='field_{$FieldName}' style='padding: 0px; margin: 0px; width: 300px; display: inline;'>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>{$inputField}{if $showLabel}<label for="{$FieldName}" style="margin-right:5px;">{$Label|sprintf,$ContentType.name_singular}</label>{/if} </td>
<td><input id="{$FieldName}_clearselection" type="button" value="{$lang.ClearSelection}" onclick="return iwp_form_field_fileupload_clearFileSelection('{$FieldName}');" /> </td>
{if $fileupload.ajax}
<td><input type="button" id="{$FieldName}_addandupload" value="Add & Upload File" onclick="return ajaxFileUpload();" /> </td>
{/if}
<td valign="top"><img onMouseOut="HideHelp('{$helpid}')" onMouseOver="ShowHelp('{$helpid}', '{$Name}', '{$HelpText}')" src='images/help.gif' width='24' height='16' border='0' /><div style='display:none' id='{$helpid}'></div></td>
</tr>
</table>
<span></span></div>
</td>
</tr>