* "Jay Blanchard" <jay.blanchard@xxxxxxxxxxxxxxxxxxxxx>: > [snip] > I know it is a often asked question, but after googling for about > 2hours and trying out some wired examples I am still not any closer to > a solution. So I was hoping to find expert advice here. > > I want to save the user the hastle of uploading a 2MB file and waiting > for a long time for an error message that the file is to big. > > Is there any usefull workaround in warning the user that he is about > to upload a 2MB file and only smaller files are supported? I tried > around with megaupload: > http://sourceforge.net/projects/megaupload > to get a progress bar and to get the file size prior to upload, but > that somehow does not work the way I want it to. > > Is there an easier solution without perl,just with PHP or/and JS? > [/snip] > > http://www.php.net/stat The OP wants a solution that is client-side -- stat() would be server-side. And, to answer the OP's question, no, there is not a reliable way to do this. You can provide some hints via the HTML form -- set hidden keys for MAX_UPLOAD_SIZE, for instance -- but many browsers ignore these. My understanding is that it's possible to use javascript in some cases to determine the file size on the upload element's population, but that is going to be unreliable as well, due to differences in client OS and browser javascript implementations. The easiest "solution" is to simply provide some warning text indicating that the file size should not exceed a certain threshold -- and give back a nice, big error message when it does so they know why the upload failed. -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php