Reply to Re: [PHP] Detect file size BEFORE upload it

Your name:

Reply:


Posted by tg-php on 10/06/05 18:40

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация