Re: Detect file size BEFORE upload it

From: Date: Thu, 06 Oct 2005 15:40:39 +0000
Subject: Re: Detect file size BEFORE upload it
Groups: php.general 
Request: Send a blank email to php-general+get-223708@lists.php.net to get a copy of this message
I know that part of the POST transaction with the client and web server involves sending the 'content-length'.. there's no way to tap into that before the file's uploaded though I guess. (example of how to manually POST using Python at leastfound here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306) Failing that.. I think someone had mentioned Java, but here's a quick and dirty way to do it in Javascript (found on: https://lists.latech.edu/pipermail/javascript/2003-April/005190.html) var myFile = new File("c:\temp\myfile.txt"); myFile.open("r"); alert('myFile length: ' + myFile.getLength()); Havn't tested it, but I'd rather use a tiny Javascript than a Java applet. My apologies if I missed something in the thread, I kind of speed read through it and wasn't going to respond, but it was nagging at the back of my brain so I had to do a quick search or two.. hah -TG = = = Original message = = = Hi, I have been trying _several_ ways to control the size of the files that can be uploaded in a form. The problem is that I was able to detect file size after complete file is transfered. I need to detect file size before all file is transfered, in order to cancel it and preserve server resources. Any ideas? Thanks in advance Ruben Rubio Rey ___________________________________________________________ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com.

« previous php.general (#223708) next »