Re: Detect file size BEFORE upload it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yeah, you're right.  I didn't test that before I posted it.

Looks like you can do it as long as your clients are running Windows and you can use Active X or another Windows trick using something like JScript, but with pure Javascript it looks bleak.

I tried to use something like this:
img = New Image();
img.src = "somefile.ext"; // NOT an image file
alert(img.fileSize);

But found out that this is an IE-only trick as well. Nobody else seems to support the filesize property on image objects.   Funny thing is, even in IE it didn't work.  Even when I actually used an image for the file name.

Oh well..  guess that Java applet might be the best way then, to keep it cross platform and all that.

-Tg

= = = Original message = = =

tg-php@xxxxxxxxxxxxxxxxxxxxxx wrote:
> var myFile = new File("c:\temp\myfile.txt");
> myFile.open("r");
> alert('myFile length: ' + myFile.getLength());

Somehow I don't think any browser is going to give JS access to 
arbitrary files on the user's system like that.

-- 
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux