473,692 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Triggering a "Exceeds Max File Size" error in freeASPUpload

2 New Member
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully.

In this modified version there are two groups that use this upload script. Members of one group get automatically re-directed after uploading.

However, this member group never gets the benefit of knowing if they've uploaded an incorrect file size or incorrect file extension.

Members from the second group do see the "exceeds max file size”, and the error “invalid filetype”.

Can you take a look at the script below and suggest how I can adjust the script so that PPL members, will trigger the "Exceeds max file size error" and "invalid filetype" error, if appropriate, before they're automatically re-directed? Thank you. Any help would be appreciated.

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <%
  3. 'option explicit
  4. Response.Expires = -1
  5. Server.ScriptTimeout = 600
  7.     MMS_GROUP_NUMBER = "2,3"
  8. Call OPEN_DB()
  9.     set PPLRS = MyConn.Execute( "SELECT * from mms_tbl_user_cate where fldUSER_ID = " & session( "PMMS_ID" ) & " AND fldCATE_ID = 3" )
  12.     PPL_GROUP_MEMBER = "Y"
  13.  END IF
  14.  set PPLRS = nothing
  15.  MyConn.close
  16.     Set MyConn = Nothing
  17. %>
  18. <!--#include virtual="aspUpload.asp" -->
  19. <!--#include VIRTUAL="app_config.asp"-->
  20. <!--#include VIRTUAL="inc_enforce.asp"-->
  21. <!--#include file="inc_header.asp"-->
  22. <%
  24. ' ****************************************************
  25.   Dim uploadsDirVar
  26.   uploadsDirVar = "C:\Input"
  27.   'response.write uploadsDirVar
  28. ' ****************************************************
  29. function OutputForm()
  30. %>
  31.     <form name="frmSend" method="POST" enctype="multipart/form-data" action="upload.asp" onSubmit="return onSubmitForm();">
  32.  <B></B><br><input name="attach1" type="file" size=35><br>
  33.     <!--File 2: <input name="attach2" type="file" size=35><br>-->
  34.     <!--File 3: <input name="attach3" type="file" size=35><br>-->
  35.     <!--File 4: <input name="attach4" type="file" size=35><br>-->
  36.     <br>
  37.  <!-- These input elements are obviously optional and just included here for demonstration purposes -->
  38.  <!--<B>Additional fields (demo):</B><br>-->
  39.  <!--Enter a number: <input type="text" name="enter_a_number" size="20"><br>-->
  40.     <!--Checkbox values: <input type="checkbox" value="1" name="checkbox_values">-1 <input type="checkbox" value="2" name="checkbox_values">-2<br>-->
  41.  <!-- End of additional elements -->
  42.     <input style="margin-top:4" type=submit value="Upload">
  43.     </form>
  44. <%
  45. end function
  46. function TestEnvironment()
  47.     Dim fso, fileName, testFile, streamTest
  48.     TestEnvironment = ""
  49.     Set fso = Server.CreateObject("Scripting.FileSystemObject")
  50.     if not fso.FolderExists(uploadsDirVar) then
  51.         TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open upload.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
  52.         exit function
  53.     end if
  54.     fileName = uploadsDirVar & "\test.txt"
  55.     on error resume next
  56.     Set testFile = fso.CreateTextFile(fileName, true)
  57.     If Err.Number<>0 then
  58.         TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open upload.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
  59.         exit function
  60.     end if
  61.     Err.Clear
  62.     testFile.Close
  63.     fso.DeleteFile(fileName)
  64.     If Err.Number<>0 then
  65.         TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."
  66.         exit function
  67.     end if
  68.     Err.Clear
  69.     Set streamTest = Server.CreateObject("ADODB.Stream")
  70.     If Err.Number<>0 then
  71.         TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."
  72.         exit function
  73.     end if
  74.     Set streamTest = Nothing
  75. end function
  76. function SaveFiles
  77.     Dim Upload, fileName, fileSize, ks, i, fileKey
  78.     Set Upload = New FreeASPUpload
  79.     Upload.setMaxFileSize 2, "k"
  80.     Upload.Save(uploadsDirVar)
  82.  ' If something fails inside the script, but the exception is handled
  83.  If Err.Number<>0 then Exit function
  84.     SaveFiles = ""
  85.     ks = Upload.UploadedFiles.keys
  86.     if (UBound(ks) <> -1) then
  87.         SaveFiles = "<B>Files uploaded:</B> "
  88.         for each fileKey in Upload.UploadedFiles.keys
  89.             SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
  90.         next
  91.     else
  92.         SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
  93.     end if
  94.  SaveFiles = SaveFiles & "" & Upload.Form("enter_a_number") & "<br>"
  95.  SaveFiles = SaveFiles & "" & Upload.Form("checkbox_values") & "<br>"
  96. end function
  97. SUB updateDB_Logout
  98.  Call OPEN_DB()
  99.  MyConn.Execute( "UPDATE mms_tbl_user SET fldSTATUS = '" & drpSTATUS(3) & "' WHERE ID = " & Session("PMMS_ID") )
  100.  IF Session("PMMS_IN") = "True" THEN
  101.             Call APPEND_LOG(False, Session("PMMS_ID"), "Logs out.", Trim(sysVAL(7)))
  102.         END IF
  103.   MyConn.close
  104.         Set MyConn = Nothing
  105.   Session.Abandon
  106.         Response.Redirect( "PPL_Logout.asp" )
  107.         Response.end
  108. END SUB
  109. %>
  111. <HTML>
  112. <HEAD>
  113. <Title>TEST</Title>
  114. <style type="text/css">
  115. body {margin: 1px 100px; padding: 1px; 0px}
  116. </style>
  117. </HEAD>
  118. <BODY leftMargin=0 topMargin=0 marginheight="0" marginwidth="0"  body {border-left: 1px solid #000; }>
  119. <SCRIPT LANGUAGE="JavaScript">errorcolor = '#eeeeee';</Script>
  120. <table cellspacing=0 border=0 cellpadding=40 width=100% align=left>
  121.  <tr>
  122.   <td align=left valign=middle>
  123. <script language="JAVASCRIPT">
  124.  var errfound = false;
  125.   function ValidLength(item, len) {
  126.      return (item.length >= len);
  127.   }
  128.   function error(elem, text) {
  129.      if (errfound) return;
  130.      window.alert(text);
  131.      elem.select();
  132.      elem.focus();
  133.      elem.style.backgroundColor=errorcolor;
  134.      errfound = true;
  135.   }
  136.   function Validate() {
  137.      errfound = false;
  138.      d=document.login
  139.      if (!ValidLength(d.members_username.value,1))error(d.members_username,"Username should not be blank.");
  140.      if (!ValidLength(d.members_password.value,1))error(d.members_password,"Password should not be blank.");
  141.      return !errfound;
  142.   }
  143. </script>
  144. <TR valign=top>
  145. <div style="border:0px solid #000000; width: 705px; padding-left: 75px; text-align:top;">
  147. <style>
  148. BODY {background-color: white;font-family:arial; font-size:12}
  149. </style>
  150. <script>
  151. function onSubmitForm() {
  152.     var formDOMObj = document.frmSend;
  153.     if (formDOMObj.attach1.value == "" && formDOMObj.attach2.value == "" && formDOMObj.attach3.value == "" && formDOMObj.attach4.value == "" )
  154.         alert("Please press the browse button and pick a file.")
  155.     else
  156.         return true;
  157.     return false;
  158. }
  159. </script>
  160. </HEAD>
  161. <BODY>
  162. <br><br>
  163. <div style="border-bottom: #A91905 2px solid;font-size:16">1. Select(Click) the Browse Button<br>
  164. 2. Choose Your File For Uploading<br>
  165. 3. Select(Click) the Upload Button<br><br></div>
  166. <%
  167. Dim diagnostics
  168. if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
  169.     diagnostics = TestEnvironment()
  170.     if diagnostics<>"" then
  171.         response.write "<div style=""margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">"
  172.         response.write diagnostics
  173.         response.write "<p>After you correct this problem, reload the page."
  174.         response.write "</div>"
  175.     else
  176.         response.write "<div style=""margin-left:5"">"
  177.         OutputForm()
  178.         response.write "</div>"
  179.     end if
  180. else
  181.     response.write "<div style=""margin-left:5"">"
  182.     OutputForm()
  183.     response.write SaveFiles()
  184.     response.write "<br><br></div>"
  186.      updateDB_Logout
  187.  end if
  188. end if
  189. %><img src="img/linkimg9.jpg" style="vertical-align: middle;" width="32" height="27" alt="" border="0" />
  190. <span style="color: #ffffff"><%=Trim(Session("PMMS_EMAIL"))%>
  191. </span>
  192. <br><br>
  193. </p></div></tr></td></tr>
  194. </table></TD></TR><!--#include file="inc_footer.asp"--></TABLE>
  195.   </TD>
  196.  </TR>
  197. </TABLE>
  198. <TABLE cellSpacing=0 valign=bottom cellPadding=0 width=100% border=0>
  199.  <TR valign=top height=4>
  200.  </TR>
  201.  <TR valign=middle height=25>
  202.   <TD class=headera2>&nbsp;<FONT class=linksmall><font face="Arial" color="#ffffff" size="2">Copyright © 2007 <a href="" target="_blank"></a>. All Rights Reserved.</FONT></TD>
  203.   <TD align=right class=headera2><font class=linksmall><font face="Arial" color="#ffffff" size="2">Email : <A href=""></A> &nbsp;&nbsp;&nbsp; </font></TD>
  204.  </TR>
  205. </TABLE>
  206. </Body>
  207. </BODY>
  208. </HTML>
Apr 18 '08 #1
1 5448
3,406 Recognized Expert Specialist
The first thing I would do is comment out the response.redire ct line, then put in a whole bunch of response.write "<!-- line 25 executed -->" style lines so you can see what lines are executing and which lines aren't. Does this make sense?

Apr 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Bob Lidgard | last post by:
Hi, I need some help. Hopefully this is trivial! I have created a special file type for my application. I can easily associate the app with the file type manually and I have even seen som code to do this as well. (MSDN - 185453) However, once the app is launched after double-clicking on the file, how can I identify which file was selected, i.e. triggered the launch. Pls point me to the right direction for search!
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm" ACTION="UploadAction.asp" METHOD="POST" enctype=multipart/form-data> <input type="file" name="fileName"> //etc ... </FORM>
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic as this is the reason (security) that I want to restrict their selection. Any help on this one will be greatly appreciated. The page is using ASP.NET.
by: IkBenHet | last post by:
Hello, I am uploading a file using this form in ASP.NET. I have also added a simpel textfield: <form runat="server" enctype="multipart/form-data"> <input type="file" id="oFile" Name="oFile" size="70" runat="Server"> <input type="text" SIZE="20" MAXLENGTH="20" id="Name" NAME="Name"> <input type="submit" id="Submit" runat="Server" value="Submit" OnServerClick="SubmitButton_Click"> </form>
by: yma | last post by:
Hi, I have a web.config file that contains <httpHandlers> section that causes "cannot load file..." error. If I delete this section, it is OK. Why did vb.net add this section? It does not add this section now. Thank you. <!-- PREVENT SOURCE CODE DOWNLOAD This section sets the types of files that will not be downloaded. As well as entering a httphandler for a file type, you must also associate that file
by: smanisankar | last post by:
hi, the following is the full page code for uploading a file to server. since i got no idea to overwrite the file, i want delete the file if the file is already uploaded. i got the folder name and filename of the file to delete from the request.QueryString("path") so i got the above error when i try to delete the file before upload. Please anyone help me to solve out from this error. <%@ Import Namespace="System.IO" %>
by: Markus | last post by:
I'm adding to my script a section that allows a thumbnail to be created and saved. I get this error: Warning: imagejpeg() : Unable to open '../uploads/thumb/' for writing: Is a directory in /home/.gobbles/mahcuz/mahcuz.com/upload/uploaded.php on line 129 And this is some of the code from the page: /* New code for thumbnails. Will on work if user selects "create thumb on upload" on the upload page */ //check to see if checkbox is...
by: .Net Sports | last post by:
I'm using Persits.upload module in ASP, and when i use the following form pointed to the object I've always used, i get a "The system cannot find the file specified" error pointing to the line of my upload.savevirtual : Set Upload = Server.CreateObject("Persits.Upload") upload.savevirtual ("test/") .. ''''error:
by: =?Utf-8?B?eHl6X2phdA==?= | last post by:
I have a winodws service which sends email using Domino. The service is installed using System Account but it is not able to send emails and gives following error - Error Message: Notes error: Could not open the ID file Error Source: NotesSession Error Stack: at Domino.NotesSessionClass.Initialize(String pPassword) at JPMorganChase.Patrol.Notification.Library.LotusNotes.Email..ctor(String NotesDatabase, String NotesPassword)
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.