From: Taras Koval Date: 2007-07-10T00:34:06+09:00 Subject: Re: Get file size before download (noobish question) Taras Koval wrote: > John Joyce wrote: >> >> On Jul 9, 2007, at 3:31 AM, Taras Koval wrote: >> >>> Guest wrote: >>>> Hi, >>>> >>>> so the subject implies what i want to do, get the file size before >>>> downloading. i've seen posts about downloading the header, so if >>>> possible, could someone give an example of this code??? >>>> >>>> also, for files without a header, i tried using :content_length_proc >>>> within the open-uri class, but it would seem that the file is being >>>> downloaded, then tested for size (from the difference in time for >>>> running my code) >>>> >>>> so if someone has any ideas as to getting filesize of a file (mp3 >>>> specifically) without a header... please help! >>>> >>>> >>> That is not possible! >>> >> If you can ask the system the file is stored on, you can get its file >> size. >> >> > Actually you can use JavaScript to get file size before uploading, I > know how to do that in IE and FF but there will be a browsers security > pop ups and user should confirm > that you script will be checking their file system. > > For IE: function getFileSize(file) { var oas = new ActiveXObject("Scripting.FileSystemObject"); var e = oas.getFile(file); var f = e.size; return f; }