file upload

  • Thread starter Thread starter Viktor Popov
  • Start date Start date
V

Viktor Popov

How could I upload files which are less than 100K only?
Thanks,

Viktor
 
How could I upload files which are less than 100K only?

Easy enough client-side if your client is happy using ActiveX, and their
security settings will permit it. Something like the following (I haven't
tested this, by the way, but it should be enough to show you how to do
it...)

<html>
<head>

<script language="JavaScript">

function getFileSize(pstrFileSpec)
{
var objFS = new ActiveXObject("Scripting.FileSystemObject");
var objFile = objFS.getFile(pstrFileSpec);
alert(objFile.size + " bytes");
}

</script>

</head>

<body>

<form name="frmTest">
<input type="file" name="txtFile">
<input type="button" name="cmdSize" value="File Size"
onClick="getFileSize(document.frmTest.txtFile);">
</form>

</body>

</html>

Alternatively, you'll have to do it server-side...
 
Mark said:
Easy enough client-side if your client is happy using ActiveX, and their
security settings will permit it. Something like the following (I haven't
tested this, by the way, but it should be enough to show you how to do
it...)

<html>
<head>

<script language="JavaScript">

function getFileSize(pstrFileSpec)
{
var objFS = new ActiveXObject("Scripting.FileSystemObject");
var objFile = objFS.getFile(pstrFileSpec);
alert(objFile.size + " bytes");
}

</script>

</head>

<body>

<form name="frmTest">
<input type="file" name="txtFile">
<input type="button" name="cmdSize" value="File Size"
onClick="getFileSize(document.frmTest.txtFile);">
</form>

</body>

</html>

Alternatively, you'll have to do it server-side...


This is a IE only 'solution'!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top