Solved

AspSmartUpload problem when checking file size error 800a0005 invalid procedure call or argument

Posted on 2006-11-03
5
611 Views
Last Modified: 2008-01-09
Hi guys,

I have a very wierd problem, when i changed my upload script by add a checking file size before upload script, it gives this error:

Microsoft VBScript runtime Error '800a0005'

Invalid procedure call or argument: 'Left'

The below is the original script and works with NO problem:

'###############  UPLOAD   #############
                        
                        Dim objUpload
                        Dim file
                        Dim intCount
                        intCount=0
                        
                        Set objUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
                        objUpload.Upload
                        
                  
                      dim loop_counter                                    
                        
                                                                                                
                        dim sqlPhoto_add, rsPhoto_add, strFileOne, photo_src, photo_name, photo_desc, photo_border                                                      
                                                                                                                        
            
                        loop_counter = 0
                        
                        for each file In objUpload.Files
                              if file.IsMissing then
                        %>
                              
                        <%
                                    
                              else
                                    
                                    file_name = file.filename
                                    Randomize
                                    rand = "_" & Int(Rnd*(9999 -1))            
                                    'file_folder = datepart("yyyy", now(), vbSunday, vbFirstJan1) & "-" & datepart("m", now(), vbSunday, vbFirstJan1) & "-" & datepart("d", now(), vbSunday, vbFirstJan1)
                                    file_name2 = Left(file_name, 4)
                                    file_name = Left(file_name2, InStr(1,file_name,".",1)-1) & rand & "." & file.FileExt
                                    file.SaveAs(getDirectory(FULL_PATH_HIRES & file_folder) & "\" & file_name)            
                        
                                    'msg = msg & "Name = " & file.Name & "\n"
                                    msg = msg & "filename = " & file.filename & "\n"            
                                    msg = msg & "FileExt = " & file.FileExt & "\n"
                                    msg = msg & "Size = " & file.Size & "\n"
                                    msg = msg & "FilePathName = " & file.FilePathName & "\n"
                                    msg = msg & "ContentType = " & file.ContentType & "\n"
                                    msg = msg & "ContentDisp = " & file.ContentDisp & "\n"
                                    msg = msg & "TypeMIME = " & file.TypeMIME & "\n"
                                    msg = msg & "SubTypeMIME = " & file.SubTypeMIME & "\n"
                                    
                                    intCount = intCount + 1
                                    res = createThumb(file_name)
                                    if (res = 0) then
                                    %>
                                          
                                    <%
                                    else            
                                    %>
                                          <script language='JavaScript'>
                                                alert("Create thumbnail fail. Please try again.");
                                                window.location="./photo_add_2.asp?id=<%= objUpload.Form("id").values %>";
                                          </script>                  
                                    <%
                                    end if
                                    
                                    sqlPhoto_add = "INSERT INTO FB_PhotoImage (PhotoCat_id,member_id,photo_src,photo_name,photo_desc,photo_border) VALUES ("& objUpload.Form("id").values &","& session("FB_UserID") &",'"& file_name &"','"& objUpload.Form("txtPhoto_name_"& loop_counter &"").values &"','"& objUpload.Form("txtPhoto_desc_"& loop_counter &"").values &"','"& objUpload.Form("optPhotoBorder_"& loop_counter &"").values &"')"
                                                                                          
                                    'response.Write(sqlPhoto_add)
                                    'response.Write("<br>")
                                    
                                    set rsPhoto_add = server.createobject("adodb.recordset")
                                    rsPhoto_add.cursorlocation = 3
                                    rsPhoto_add.open sqlPhoto_add, adoConn                                          
                                    
                              end if
                              loop_counter = loop_counter +1
                        next
'##################################################################

But then when i changed:

if file.IsMissing then
.                                    
.
.
else

TO

if file.Size > 256000 then
                                    %>
                                          <script language='JavaScript'>
                                                            alert("Your file size cannot exceed 250KB");
                                                            window.location="./photo_add_2.asp?id=<%= objUpload.Form("id").values %>";
                                          </script>
                                          
                                    <%                                                      
                                    
                              
                              else

It gives the errors, I have no idea why, is it because I attempt to use file.Size? Anyone know why?? Thanks~!
0
Comment
Question by:huang_ck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 20

Accepted Solution

by:
Gawai earned 250 total points
ID: 17872954
to check file size pls refer

http://www.sitiasp.it/dllDoc/aspSmartUpload/help/FileObject.htm

Size

The Size property contains the file's size.

Syntax
.Size

Return Value
Returns a Long value.

Example
<%
Response.Write("Size=" & MyUpLoad.Files.Item(2).Size)
%>

0
 
LVL 58

Assisted Solution

by:amit_g
amit_g earned 250 total points
ID: 17874288
In your original script, change

if file.IsMissing then
.                              
.
.
else

to

if file.IsMissing then
.                              
.
.
elseif file.Size > 256000 then
%>
                                   <script language='JavaScript'>
                                                  alert("Your file size cannot exceed 250KB");
                                                  window.location="./photo_add_2.asp?id=<%= objUpload.Form("id").values %>";
                                   </script>
<%
else
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Display first 3 lines of text from database field, vbscript asp 4 62
ASP/VB email question 4 62
Clear input text 15 26
Display if field is NOT "" or NOT null 6 22
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question