Re: Detect file size BEFORE upload it
| From: | tg-php at gryffyndevelopment dot com | Date: | Thu, 06 Oct 2005 19:29:45 +0000 |
| Subject: | Re: Detect file size BEFORE upload it | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-223713@lists.php.net to get a copy of this message | ||
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@gryffyndevelopment.com 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.