This is a discussion on upload file size within the PHP General forums, part of the PHP Programming Forums category; Hi i really need help with an upload script. right now i use if ($HTTP_POST_FILES['userfile']['size']>$maxsize) { echo &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi
i really need help with an upload script. right now i use if ($HTTP_POST_FILES['userfile']['size']>$maxsize) { echo "File too big"; exit; } to determine if the file is larger than allowed. but the problem is, that if the file IS larger, it is still first fully uploaded and then checked. i tested it several times - if the file is much larger than allowed, it displays the error message but the page loads a lot longer and my computer is sending the file to the server. this could really kill my bandwidth. is there a way to check the file size without fully uploading the file? thanks joe |
|
|||
|
Gerard Samuel wrote:
>On Friday 14 November 2003 12:48 pm, joe wrote: > > >> is there a way to check the file size >>without fully uploading the file? >> >> >> > >No there isnt, well at least not via php... > correct. There are two solutions you can upload with a java applet, the applet can be configured to lock the upload at a predefined limit. Would save you a lot of bandwidth. The second is to upload via perl script, which can check the Content-length header *before* processing the file upload and block it. In fact megaupload - the php upload progress bar that i did some time ago has this feature. sorry about the belated reply message had been stuck in a que.. > > > -- Raditha Dissanayake. ------------------------------------------------------------------------ http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. |
|
|||
|
wich kind of files are we talking about?
pictures or others? "Gerard Samuel" <php-general@trini0.org> skrev i meddelandet news:200311141338.52951.php-general@trini0.org... > On Friday 14 November 2003 12:48 pm, joe wrote: > > is there a way to check the file size > > without fully uploading the file? > > > > No there isnt, well at least not via php... |
|
|||
|
Joe
You would have to write a form validation script to check the file size. Mike Joe wrote: > Hi > i really need help with an upload script. > right now i use > if ($HTTP_POST_FILES['userfile']['size']>$maxsize) { echo "File > too big"; > exit; } > to determine if the file is larger than allowed. > but the problem is, that if the file IS larger, it is still first fully > uploaded and then checked. i tested it several times - if the file is > much > larger than allowed, it displays the error message but the page loads a > lot > longer and my computer is sending the file to the server. > this could really kill my bandwidth. is there a way to check the file > size > without fully uploading the file? > thanks > joe ##-----------------------------------------------# Article posted from PHP Freaks NewsGroup http://www.phpfreaks.com/newsgroup Get Addicted: php.genera ##-----------------------------------------------## |
|
|||
|
Joe
You would have to write a javascript form validation script to check the file size. Mike Joe wrote: > Hi > i really need help with an upload script. > right now i use > if ($HTTP_POST_FILES['userfile']['size']>$maxsize) { echo "File > too big"; > exit; } > to determine if the file is larger than allowed. > but the problem is, that if the file IS larger, it is still first fully > uploaded and then checked. i tested it several times - if the file is > much > larger than allowed, it displays the error message but the page loads a > lot > longer and my computer is sending the file to the server. > this could really kill my bandwidth. is there a way to check the file > size > without fully uploading the file? > thanks > joe ##-----------------------------------------------# Article posted from PHP Freaks NewsGroup http://www.phpfreaks.com/newsgroup Get Addicted: php.genera ##-----------------------------------------------## |