The script code looks, though a bit clunky, like it should work cross browser. I take it this keys off of a form with a:
HTML Code:
<input type="file" id="filename">
element in it, right?
In any case, access to the value property of file inputs is severely restricted due to security reasons. In some browsers this can even frustrate the most innocent seeming code. But to really get an idea of why there is a problem in this particular case, we would need to see the page, or at least the form, including the code that shows how your function is invoked from it.
Note: Though very unlikely to be the problem, the language attribute has been deprecated for the script tag, and the type attribute is now required, use:
Code:
<script type="text/javascript">
not:
Code:
<script language="javascript">
Added Later:
Your script code worked fine with this test form:
HTML Code:
<form action="#" onsubmit="return Checkfiles();">
<input type="file" id="filename">
<input type="submit" value="Go!">
</form>
Bookmarks