This topic is locked

Image Upload

7/25/2004 1:53:33 PM
ASPRunnerPro General questions
P
petski author

I have looked in the code for the file upload and no where can I find code to restrict image file size (kb)
I would like to restrict image sizes to 35 kb.
Thanks for the help.
Scott

Sergey Kornilov admin 8/2/2004

Scott,
sure you can do this. You need to modify uploader.asp file for this purpose. Please see my changes in bold.

**

if Request.TotalBytes>35000 then

Response.Write "Maximum picture size is 35Kb. Please reduce file size or upload another picture.

"

end if
if Request.TotalBytes>0 and Request.TotalBytes<=35000 then

' Instantiate Upload Class

Set objUpload = New clsUpload
' Grab the file name

strFileName = objUpload.Fields("File1").FileName
Set objConn = Server.CreateObject("ADODB.Connection")

Set objRs = Server.CreateObject("ADODB.Recordset")
objConn.Open strConnection
objRs.Open "SELECT " & strPK & ", " & AddWrappers(strField) & " FROM " & AddWrappers(strTable) & " WHERE " & sWhere, objConn, adOpenKeyset, adLockOptimistic

objRs.Fields(strField).AppendChunk objUpload("File1").BLOB & ChrB(0)
objRs.Update

objRs.Close
Set objRs = Nothing

Set objConn = Nothing

Set objUpload = Nothing

Response.Write "File has been saved in database<BR><BR>"

end if**


I hope this helps.