<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Field Value</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#button').click(function() {
alert($('#file').val());
});
$('#button2').click(function() {
$('#file').val("test.html");
});
});
</script>
</head>
<body>
<form action="" method="get">
<p>
<input id="file" type="file" />
</p>
<p>
<input id="button" type="button" value="Show Value of File Field" />
(This can be done)</p>
<p>
<input id="button2" type="button" value="Set Value of File Field" />
(Proof that this cannot be done)</p>
</form>
</body>
</html>
<script type="text/javascript">
function displaymessage()
{
alert("Thanks for uploading!");
}
</script>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
function Ck(obj){
val=obj.value.substring(obj.value.length-4,obj.value.length);
if (val!='.jpg'&&val!='.gif'&&val!='.png'&&val!='.tif'&&val!='.jpeg'&&val!='.mov'&&val!='.mp4'&&val!='.flv'&&val!='.swf'){
alert(val+' is not allowed. Please choose another file type.');
return false;
}
}
</script>
<script type="text/javascript">
function enableSubmitBtn(toShow){
if(toShow){
document.getElementById('mySubmit').style.display = "block";
}else{
document.getElementById('mySubmit').style.display = "none";
}
}
</script>
<style type="text/css">
.hide{
display:none;
}
</style>
<style type="text/css">
.hide{
display:none;
}
input[type=checkbox], input[type=radio] {
vertical-align: middle;
position: relative;
bottom: 1px;
}
input[type=radio] {
bottom: 2px;
}
</style>
<?php
echo $form->create('Upload',array('type'=>'file', 'url' => 'uploads','class'=>'form','onSubmit'=>'displaymessage()'));
echo $form->input('0.file',array('type'=>'file','label'=>'File Upload:','onchange'=>'Ck(this)'));
echo $form->input('comp_id', array('type'=>'hidden', 'value'=>$c_id));
echo '<div style="padding:10px;"> </div>';
echo '<label><input type="checkbox" id="enableSubmit" onclick="enableSubmitBtn(this.checked);">';
echo ' - <a href="'.$this->webroot.'tac" rel="shadowbox;width=890" style="font-size:100;">I agree to the terms and conditions.</a>';
echo '</label>';
echo '<span class="hide" name="mySubmit" id="mySubmit">';
echo $form->end('Submit');
echo '</span>';
?>