Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 20
2.x, 3.x
MaxBytes setting seems to have no effect
The MaxBytes property has been set before issuing the .SaveAs method, yet the the property seems to be ignored. The resulting file on disk is actually much larger than the MaxBytes setting.
The MaxBytes property allows you to set the maximum size of the file to stored on the web server. This property prevents malicious or uninformed users from filling up the disk of the web server.

Like the Path property, MaxBytes must be set before referencing any form elements. As soon as a form element is referenced, the upload will be processed and files will be written to disk. If MaxBytes is set after referencing a form element, it will be ignored, i.e.

set oUpl = Server.CreateObject("SoftArtisans.FileUp")

'--- The entire upload will be processed here. Cache files are written now. myname = oUpl.Form("myname")

'--- WRONG: This will have no effect. It is too late, as the files are already written. oUpl.MaxBytes = 500000 oUpl.SaveAs "c:\uploads\myfile.ext"

Instead, MaxBytes should be set immediately after instanciating SA-FileUp, i.e.
set oUpl = Server.CreateObject("SoftArtisans.FileUp")

'--- RIGHT: Set MaxBytes before referencing the form. oUpl.MaxBytes = 500000

'--- The entire upload will be processed here. Cache files are written now myname = oUpl.Form("myname") oUpl.SaveAs "c:\uploads\myfile.ext"

Created : 12/1/2002 12:00:00 AM (last modified : 11/13/2001 11:00:00 AM)
Rate this article!