huang_ck
asked on
AspSmartUpload problem when checking file size error 800a0005 invalid procedure call or argument
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("aspSm artUpload. SmartUploa d")
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(F ULL_PATH_H IRES & 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_a dd_2.asp?i d=<%= objUpload.Form("id").value s %>";
</script>
<%
end if
sqlPhoto_add = "INSERT INTO FB_PhotoImage (PhotoCat_id,member_id,pho to_src,pho to_name,ph oto_desc,p hoto_borde r) VALUES ("& objUpload.Form("id").value s &","& session("FB_UserID") &",'"& file_name &"','"& objUpload.Form("txtPhoto_n ame_"& loop_counter &"").values &"','"& objUpload.Form("txtPhoto_d esc_"& loop_counter &"").values &"','"& objUpload.Form("optPhotoBo rder_"& loop_counter &"").values &"')"
'response.Write(sqlPhoto_a dd)
'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_a dd_2.asp?i d=<%= objUpload.Form("id").value s %>";
</script>
<%
else
It gives the errors, I have no idea why, is it because I attempt to use file.Size? Anyone know why?? Thanks~!
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("aspSm
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
file.SaveAs(getDirectory(F
'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_a
</script>
<%
end if
sqlPhoto_add = "INSERT INTO FB_PhotoImage (PhotoCat_id,member_id,pho
'response.Write(sqlPhoto_a
'response.Write("<br>")
set rsPhoto_add = server.createobject("adodb
rsPhoto_add.cursorlocation
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_a
</script>
<%
else
It gives the errors, I have no idea why, is it because I attempt to use file.Size? Anyone know why?? Thanks~!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.