Welcome Guest, Not a member yet? Register   Sign In
Need help to get file size while uploading
#1

[eluser]nandish[/eluser]
I try to avoid uploading images according to file size but the thing is am not able to get file size with the help of javascript



function getFilesize(){
var size = document.images['uimgs'].fileSize;
return size;
}
function validate(){
alert(getFilesize()Wink;
}
If i run this script its return undefined in both IE AND FIREFOX


Thanks in Advance
#2

[eluser]Yash[/eluser]
Only IE supports javascript using activeX power.
Code:
<html>
<head>
[removed]
function A()
{
var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = document.a.b.value;
var e = oas.getFile(d);
var f = e.size;
alert(f + " bytes");
}
[removed]
</head>
<body>
<form name="a">
<input type="file" name="b">
<input type="button" name="c" value="SIZE">
</form>
</body>
</html>

For others use FTP class
#3

[eluser]Colin Williams[/eluser]
You could silently (asynchronously) post the upload form to an iframe, which figures out the size on the server and reports back via the iframe. Although, it sounds like you want to avoid the initial upload altogether if the file is too big.

A viable solution might be to use ini_set() and lower the max_upload_size setting for this particular process (in the particular Controller method that handles the upload).




Theme © iAndrew 2016 - Forum software by © MyBB