Advertisement

04.22.2008 at 12:39AM PDT, ID: 23342055
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Classic ASP -> How to determine max image size, and image size when uploading file

Asked by speedygonzalez in Active Server Pages (ASP), VB Script

Tags:

Hello,
        I am using a free upload class I obtained (not sure where I got it from to be honest, but have had a it for a few years) to aid in uploading image files from an classic ASP form page.

The upload.class contents are as attached file upload.txt.

Within my ASP page I process the uploaded data from my form page within code as per the attached code snippet below

My upload code, and class works fine for uploading many image files, however throws an error for a certain file size and above.

The error is as follows:

Script error detected at line 290.
Source line: Next
Script details:
280 End if
281
282
283 ' Convert the binary data to Ascii
284 bytBinaryData = oFile.BinaryData
285 nLength = LenB(bytBinaryData)
286
287
288
289 For nIndex = 1 To nLength
290 sNewData = sNewData & Chr(AscB(MidB(bytBinaryData, nIndex, 1)))
291 Next
292
293 ' Save the file to the file system
294 sPath = Server.MapPath("..\..\images\dynamic") & "\"
295
296 Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
297 oFSO.OpenTextFile(sPath & sFileName, nForWriting, True).Write sNewData
298 Set oFSO = Nothing
299
300 Set oFile = Nothing


-> Do you know how I can determine the file size uploaded in my code, and determine the maximum file size my code allows me to upload?

At present I do not know the max file size, or if I can expend this somehow in my code.

Any help on this would be very much appreciated.

Thanking you in advance!

Speedy.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
<!--This include must appear to verify the administrator is logged in - NEVER DELETE THIS FROM THE ADMINISTRATION SECTION-->
<!--#include file="../ssi/adminlogonStatus.txt"-->
<!--#INCLUDE FILE="upload.class"-->
<%
Dim oUpload
Dim oFile
Dim sFileName
Dim oFSO
Dim sPath
Dim sNewData
Dim nLength
Dim bytBinaryData
 
 
Const nForReading = 1
Const nForWriting = 2
Const nForAppending = 8
 
' grab the uploaded file data
Set oUpload = New clsUpload
Set oFile = oUpload("image")
 
 
 
 
page_Key = Request.Querystring("page_Key") 
elementOrder = Request.Querystring("elementOrder")
 
' parse the file name
sFileName = oFile.FileName
If Not InStr(sFileName, "\") = 0 Then
  sFileName = Mid(sFileName, InStrRev(sFileName, "\") + 1)
Else
  response.redirect("addImage1.asp?from_error=true&page_Key=" & page_Key & "&elementOrder="&elementOrder)
End if
 
 
' Convert the binary data to Ascii
bytBinaryData = oFile.BinaryData
nLength = LenB(bytBinaryData)
 
 
 
For nIndex = 1 To nLength
  sNewData = sNewData & Chr(AscB(MidB(bytBinaryData, nIndex, 1)))
Next
 
' Save the file to the file system
sPath = Server.MapPath("..\..\images\dynamic") & "\"
 
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
oFSO.OpenTextFile(sPath & sFileName, nForWriting, True).Write sNewData
Set oFSO = Nothing
 
Set oFile = Nothing
Set oUpload = Nothing
 
fileDetail = sPath & sFileName
 
 
%>
Attachments:
 
copy of upload.class file
 
[+][-]04.22.2008 at 01:59PM PDT, ID: 21415555

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), VB Script
Tags: Classic ASP/VBScript
Sign Up Now!
Solution Provided By: _Stilgar_
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628