...

View Full Version : Need help with file uploading limit on ASP/MS.Access



mctnesh
02-24-2006, 11:22 AM
Hello Hi,

Im a newbie here.
Was asked to take a look at a script and to adjust the file uploading limit to more than 1MB. Currently, only files (.pdf) not more than 50kb can be uploaded to the database. Other than that, the script works fine.
Can someone help me.

mctnesh
02-24-2006, 11:22 AM
Here's the source code, where do i alter? :-

UPLOAD PAGE (admin.asp)
========================

<%sub additem%>
<center>
<FORM name="additem" METHOD="POST" ENCTYPE="multipart/form-data" action="postadditem.asp" onSubmit="return CheckFieldAddItem();">
<link rel="stylesheet" href="../../uplan.css">
<table width="80%">
<tr>
<td class="tablebg" colspan="2">
<p align="center" class="headline"><img src="../button/bar_additem.gif" width="450" height="24">
</td>
</tr>
<tr>
<td height="31" align="right" class="text" valign="top">Item Id</td>
<td height="31" class="text">
<input type="text" name="itemid" size="32">
</td>
</tr>
<tr>
<td align="right" class="text" valign="top">Item Name</td>
<td class="text">
<input type="text" name="itemname" size="32">
</td>
</tr>
<tr>
<td align="right" class="text" valign="top">&nbsp;</td>
<td class="text">
<input type="hidden" name="itemdesc" cols="28">
</td>
</tr>
<tr>
<td align="right" class="text" valign="top">Item Details Description</td>
<td class="text">
<textarea rows="7" name="itemdesc2" cols="28"></textarea>
</td>
</tr>
<tr>
<td align="right" class="text" valign="top">Item Thumnail Picture <br>
(recomanded 80 x 80 pixels)</td>
<td class="text">
<input type="file" name="itempic" size="32" class="text">
</td>
</tr>
<tr>
<td align="right" class="text" valign="top">Item Enlarge Picture<br>
(recomanded 300 x 300 pixels) </td>
<td>
<input type="file" name="itempic2" size="32" class="text">
</td>
</tr>
<tr background="../button/spacer.gif">

<td width="91" class="title2" height="35">
<div align="right"> Item PDF File </div>
</td>

<td width="192" height="35" class="title2">
<input type="file" name="itempdf" size="26" >
</td>

</tr>
<tr background="../button/spacer.gif">

<td width="91" class="title2">
<div align="right"><br>
Show <br>
</div>
</td>
<td width="192" height="30" class="title2">
<Input Type=Checkbox name=picOption> Picture <%=" "%> <Input Type=Checkbox name=pdfOption> PDF File
</td>


</tr>
<tr class="text">
<td>&nbsp;</td>
<td>
<p>
<input type="submit" value="Submit" name="B1" onclick()="CheckFieldAddItem();">
<input type="reset" value="Reset" name="B2">
</p>
</td>
</tr>
<input type="hidden" name="id" value=<%=request.querystring("id")%>>
</table>
<p><br>
<a href="javascript:window.close()"><img border="0" src="../button/close.gif" width="38" height="17"></a></p>
</form>
</center>
<%end sub%>
Edit/Delete Message

mctnesh
02-24-2006, 11:23 AM
POST ADD PAGE (postadditem.asp)
=================================

<!--#include file="classlib.asp"-->
<!--#include file="connect.asp"-->
<!--#includes file="clsUpload.asp"-->
<%
Call CheckLoginInfo

sub DoAdmin
end sub

%>
<%
Const nForReading = 1
Const nForWriting = 2
Const nForAppending = 8

dim oUpload
dim oFile
dim sFileName
dim DataRead
dim idxFile
dim sPath
dim oFSO
dim values(10)
dim files (2)
dim i
i=1

Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
sPath = Server.MapPath("../images")&"/"

Set oUpload = New clsUpload
for idxFile = 0 to oUpload.Count
if oUpload(idxFile).FileName <> "" then
Set oFile = oUpload(idxFile)
sFileName = oUpload.ShortName(oFile.FileName)
DataRead = oUpload.Bin2Asc(oFile)
' Save the file to the file system
oFSO.OpenTextFile(sPath & sFileName, nForWriting, True).Write DataRead
'response.write len(DataRead) & "," & oFile.length & "<br>"
files(i)=sFileName
i=i+1
else
values(idxFile) = oUpload(idxFile).value

end if
next


itemid=values(0)
itemname=values(1)
itemdesc=values(2)
itemdesc2=values(3)
id=values(7)
itempic=files(1)
itempic2=files(2)
types="z"


if id<>"" then
set objconnect=server.createobject("ADODB.Connection")
objconnect.open gsConnect
ssql2="select * from item where id="&id&""
set rs2=objconnect.execute(ssql2)

threadid = rs2("threadid")
parentid = rs2("id")

else
set objconnect=server.createobject("ADODB.Connection")
objconnect.open gsConnect
ssql3="select * from item "
set rs3=objconnect.execute(ssql3)
rs3.movelast
threadid=rs3("id")+1
parentid=0
end if




ssql4=""
sSQL4 = sSQL4 & "INSERT INTO item ( threadid, parentid, itemid, itemname, itemdesc, itemdesc2,type, itempic, itempic2) "
sSQL4 = sSQL4 & "VALUES(" & SQLVal(threadid) & ", "
sSQL4 = sSQL4 & SQLStr(parentid) & ", "
sSQL4 = sSQL4 & SQLStr(itemid) & ", "
sSQL4 = sSQL4 & SQLStr(itemname) & " ,"
sSQL4 = sSQL4 & SQLStr(itemdesc) & " ,"
sSQL4 = sSQL4 & SQLStr(itemdesc2) & " ,"
sSQL4 = sSQL4 & SQLStr(types) & " ,"
sSQL4 = sSQL4 & SQLStr(itempic) & " ,"
sSQL4 = sSQL4 & SQLStr(itempic2) & " )"

objConnect.Execute(ssql4)


%>
<body bgcolor="#d3e7ff">
<p align="center">
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><font face="Verdana"><b>Posted Successfully!</b></font> </p>
<p align="center"><a href="javascript:window.close()"><img border="0" src="../button/close.gif" ></a>

mctnesh
02-24-2006, 11:23 AM
CLASSLIB (classlib.asp)
=======================

<!-- #include file="connect.asp" -->
<%


'Dim gsConnect

Function SQLVal(pvValue)
Dim sTemp

Select Case VarType(pvValue)
Case 0, 1:
SQLVal = "NULL"
Case 2, 3, 4, 5, 6:
SQLVal = "" & pvValue
Case 8: 'String
sTemp = Trim(pvValue)
On Error Resume Next
SQLVal = "" & CDbl(sTemp)
If Err.Number <> 0 Then
Err.Clear
SQLVal = "NULL"
End If
Case 11:
SQLVal = "" & Cint(pvValue)
Case Else
SQLVal = "NULL"
End Select
End Function

Function NumToStrLeadDigits(pvValue, piDigits)
Dim sTemp
sTemp = Trim("" & pvValue)
Do While Len(sTemp) < piDigits
sTemp = "0" & sTemp
Loop
NumToStrLeadDigits = sTemp
End Function


Function SQLStr(pvValue)
Dim sTemp
Select Case VarType(pvValue)
Case 0, 1:
SQLStr = "NULL"
Case 2, 3, 4, 5, 6:
sTemp = "" & pvValue
sTemp = Replace(sTemp, "'", "''")
SQLStr = "'" & sTemp & "'"
Case 7: 'DateTime
sTemp = FormatDateTime(pvValue)
sTemp = Replace(sTemp, "'", "''")
SQLStr = "'" & sTemp & "'"
Case 8: 'String
sTemp = pvValue
sTemp = Replace(sTemp, "'", "''")
If Len(Trim(sTemp)) > 0 Then
SQLStr = "'" & sTemp & "'"
Else
SQLStr = "NULL"
End If
Case Else
SQLStr = "NULL"
End Select
End Function

Function SQLDate(pvDate)
Select Case VarType(pvDate)
Case 7: 'Date
If giSQLDateAsSystem Then
SQLDate = gsSQLDateDelimiter & FormatDateTime(pvDate,2) & " " & FormatDateTime(pvDate,4) & gsSQLDateDelimiter
Else
SQLDate = gsSQLDateDelimiter & NumToStrLeadDigits(Year(pvDate),4) & NumToStrLeadDigits(Month(pvDate),2) & NumToStrLeadDigits(Day(pvDate),2) & " " & FormatDateTime(pvDate,4) & gsSQLDateDelimiter
End If
Case 8: 'String
If IsDate(pvDate) Then
If giSQLDateAsSystem Then
SQLDate = gsSQLDateDelimiter & FormatDateTime(CDate(pvDate),2) & " " & FormatDateTime(CDate(pvDate),4) & gsSQLDateDelimiter
Else
SQLDate = gsSQLDateDelimiter & NumToStrLeadDigits(Year(CDate(pvDate)),4) & NumToStrLeadDigits(Month(CDate(pvDate)),2) & NumToStrLeadDigits(Day(CDate(pvDate)),2) & " " & FormatDateTime(CDate(pvDate),4) & gsSQLDateDelimiter
End If
Else
SQLDate = "NULL"
End If
Case Else
SQLDate = "NULL"
End Select
End Function




Sub CheckLoginInfo
If IsLoggedOn Then
Call DoAdmin
Else
response.redirect("loginerror.asp")
End If
End Sub

Function IsLoggedOn()
If Session("LoggedOn") = "YES" Then
IsLoggedOn = True
Else
IsLoggedOn = False
End If
End Function












Sub CheckLoginInfo4
If IssssLoggedOn Then
Call DoAdmin
Else
response.redirect("login2.asp")
End If
End Sub

Function IssssLoggedOn()
If Session("LoggedOn4") = "YES" Then
IssssLoggedOn = True
Else
IssssLoggedOn = False
End If
End Function





Function AddLog()
userids = CatRS.fields("username")
usertype = CatRS.fields("usertype")
webaddress = naofacc
events = "add new record"
CurrentDate = Now


Set GobjConnect = server.createobject("ADODB.Connection")
GobjConnect.open gsConnect

rSQL = ""
rSQL = rSQL & "INSERT INTO log ( userid, usertype, webaddress, events ,CurrentDate) "
rSQL = rSQL & "VALUES(" & SQLStr(userids) & ", "
rSQL = rSQL & SQLStr(usertype) & ", "
rSQL = rSQL & SQLStr(webaddress) & ", "
rSQL = rSQL & SQLStr(events) & ", "
rSQL = rSQL & SQLDate(CurrentDate) & " )"

GobjConnect.Execute(rSQL)
End Function










Sub AdminNavigation

Response.Write("<CENTER><BIG>Classified Administration</BIG></CENTER><BR></FONT>")
Response.Write("<FONT FACE =" & chr(34) & sFont & chr(34) & "><CENTER>")
Response.Write("<A HREF=""adminaddcat.asp"">Add a Category</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
Response.Write("<A HREF=""admindeletecat.asp"">Delete a Category</A><BR>")
Response.Write("OR <BR> Navigate to the message that you want to edit or delete.<P>")
Call DoAdmin
End Sub
%>
Edit/Delete Message

mctnesh
02-24-2006, 11:24 AM
clsUpload.asp



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum