ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!

Download and Activate to enter!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Download to Enter | Contest Rules

Learn More!

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 23rd, 2009, 02:47 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
(Regarding this thread: http://forums.aspfree.com/code-bank...ures-94647.html)

I am Getting an error saying that

Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: 'index'


I get this error when I include the 2nd line fro the following two lines.

fileIndex = GetFileIndexByName(objUpload, "c_pic_real")
PhotoExtension=objUpload.File(fileIndex).contentTy pe


Any Idea????

CB

Last edited by Shadow Wizard : April 6th, 2009 at 09:22 AM.

Reply With Quote
  #2  
Old March 23rd, 2009, 02:55 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
Quote:
Originally Posted by Computer-bot
I am Getting an error saying that

Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: 'index'


I get this error when I include the 2nd line fro the following two lines.

fileIndex = GetFileIndexByName(objUpload, "c_pic_real")
PhotoExtension=objUpload.File(fileIndex).contentTy pe


Any Idea????

CB
yep - you didn't use any file input named "c_pic_real" or you maybe have it, but uploaded no file
using it. empty file inputs won't result in file.

you should always use sanity check to avoid such errors:
Code:
fileIndex = GetFileIndexByName(objUpload, "c_pic_real")	
If fileIndex>=0 And fileIndex<=objUpload.FileCount Then
   PhotoExtension = objUpload.File(fileIndex).contentType
Else
   'no such file, nothing to do
End If


if you have one file only, use this code instead no need for using name:
Code:
If objUpload.FileCount=1 Then
   PhotoExtension = objUpload.File(0).contentType
End If

Reply With Quote
  #3  
Old March 23rd, 2009, 03:27 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Thanks Shadow. The alternate code you gave worked. But Why isn't the old one working.

This is the form code

<th scope="row"><div align="left">Channel Display Picture</div></th>
<td><div align="left">
<input name="c_pic" type="file" tabindex="3" /></div></td>
<tr> <input type="hidden" name="c_pic_real" /> </tr>


And thats the ASP Code

fileIndex = GetFileIndexByName(objUpload, "c_pic_real")
PhotoExtension=objUpload.File(fileIndex).contentTy pe
T_Length=Len(PhotoExtension)

Reply With Quote
  #4  
Old March 23rd, 2009, 04:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
the GetFileIndexByName method is expecting the name of the actual file input,
not hidden input.

if you'll change to GetFileIndexByName(objUpload, "c_pic") it should work, but
you still better have the sanity check code.

Reply With Quote
  #5  
Old March 23rd, 2009, 05:04 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Thanks. I always use the sanity checks. this was just a test code.

CB

Reply With Quote
  #6  
Old March 23rd, 2009, 05:09 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Its still giving the same error. I've used the hidden file name in another code of mine and it works perfect.
???????????
CB

Reply With Quote
  #7  
Old March 23rd, 2009, 05:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
Quote:
Originally Posted by Computer-bot
Its still giving the same error. I've used the hidden file name in another code of mine and it works perfect.
???????????
CB
post your current code, tell in what line it happens and I'll help you fix it.

Reply With Quote
  #8  
Old March 23rd, 2009, 06:44 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Code:
<%
Function GetFileIndexByName(objUpload, strName)
	Dim x, curName, strToSearch
	For x=0 To objUpload.FileCount-1
		curName = LCase(objUpload.File(x).FileName)
		strToSearch = "\" & curName
		If Right(LCase(objUpload(strName)), Len(strToSearch))=strToSearch Then
			GetFileIndexByName = x
			Exit Function
		End If
	Next
	GetFileIndexByName = -1
End Function
%>

<head>
<!--#include file="../include/File.asp"-->
<script type="text/javascript">
function StoreFileNames(objForm) {
	for (var i = 0; i < objForm.elements.length; i++) {
		var element = objForm.elements[i];
		if (element.type == "file")
			objForm.elements[element.name + "_real"].value = element.value;
	}
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add_Channels</title>
</head>

<body>
<% If Request.ServerVariables("REQUEST_METHOD") <> "POST" then %>

<!-- METADATA TYPE="typelib" FILE="c:\Program Files\Common Files\System\ado\msado15.dll" -->
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="737" border="0">
    <tr>
      <th width="224" scope="col"><div align="left">Channel Name </div></th>
      <th width="503" scope="col"><div align="left">
        <input name="C_Name" type="text" id="C_Name" tabindex="1" />
      </div></th>
    </tr>
    <tr>
      <th valign="top" scope="row"><div align="left">Channel Description </div></th>
      <td><div align="left">
        <textarea name="C_Desc" cols="50" rows="7" id="C_Desc" tabindex="2"></textarea>
      </div></td>
    </tr>
    <tr>
      <th scope="row"><div align="left">Channel Display Picture</div></th>
      <td><div align="left">
        <input name="c_pic" type="file" tabindex="3" /></div></td>
		<tr> <input type="hidden" name="c_pic_real" /> </tr>
      
    
    <tr>
      <th scope="row"><div align="left">Please Type the Code </div></th>
      <td><input name="Captcha" type="text" tabindex="4" id="Captcha" /><img src="../include/aspcaptcha.asp" alt="This Is CAPTCHA Image" width="86" height="21" /></td>
    </tr>
    <tr>
      <th colspan="2" scope="row"><div align="left">
        <input name="C_Submit" type="submit" id="C_Submit" tabindex="5" value="Submit" />
      </div>        
      <div align="left"></div></th>
    </tr>
  </table>
</form>


<%
Else
	
	Set objUpload = new ShadowUpload
	C_Captcha = objUpload("Captcha")

'	If CheckCAPTCHA(C_Captcha) = False Then
'		Response.write("Wrong Code Entered")
'	Else

		Dim C_Name
		Dim C_Desc
		Dim C_Captcha
		Dim C_TempID
		Dim P_TempID
		Dim ValRand
		Dim Channel_Folder
		
		Highest=32767
		Lowest=10
	
		'################################ CONNECTION AND RECORDSET INITIATION ################################################

		Set objConn1 = Server.CreateObject("ADODB.Connection")
		Set objRs1   = Server.Createobject("ADODB.Recordset")
		Set objRs2   = Server.CreateObject("ADODB.Recordset")
		
		objConn1.Open strConnect

		objRs1.Open "Select * From Channels" , ObjConn1
		objRs2.Open "Select channel_folder from Meta_Info", objConn1
		
		'#################################################  ##################################################  #################
		

		'############################################ Creating Random Values for Channel_ID #################################
		

		strSQL1 = "Select COUNT(*) As MyCount From Channels"			
		TRecords = objConn1.Execute(strSQL1)						
		If TRecords("MyCOunt") <> "0" Then

			ObjRs1.MoveFirst
			Randomize

			C_TempID = objRs1.Fields("Channel_ID")

			For x=1 To 50						
				Val_Rand = CStr(CLng((Highest-Lowest + 1) * Rnd + Lowest))	
				If Val_Rand < 32767 and Val_Rand > 10 Then Exit For
			Next
				
			Do
				If Val_Rand <> C_TempID Then 
					objRs1.MoveNext
					If objRs1.EOF = False Then C_TempID = objRs1.Fields("Channel_ID")
			
				Else
					objRs1.MoveFirst
					Randomize
					For x=1 To 50						
						Val_Rand = CStr(CLng((Highest-Lowest + 1) * Rnd + Lowest))	
						If Val_Rand < 32767 and Val_Rand > 10 Then Exit For
					Next
					C_TempID = objRs1.Fields("Channel_ID")
				End If					
			Loop While objRs1.EOF = False			
				
		End If
		
		
		'#################################################  ##################################################  #######################



		'############################# Generating Random Value for Picture Name and Uploading the Picture #########################
		

		strSQL1 = "Select COUNT(*) As MyCount From Channels"			
		TRecords = objConn1.Execute(strSQL1)						
		If TRecords("MyCOunt") <> "0" Then

			ObjRs1.MoveFirst
			Randomize

			P_TempID = objRs1.Fields("Channel_Pic")
			P_TempID = Left(P_TempID, InStrRev(P_TempID, ".")-1)

			For x=1 To 50						
				Val_Rand2 = CStr(CLng((Highest-Lowest + 1) * Rnd + Lowest))	
				If Val_Rand2 < 32767 and Val_Rand > 10 Then Exit For
			Next
				
			Do
				If Val_Rand2 <> P_TempID Then 
					objRs1.MoveNext
					If objRs1.EOF = False Then 
						P_TempID = objRs1.Fields("Channel_Pic")
						P_TempID = Left(P_TempID, InStrRev(P_TempID, ".")-1)
					End If
			
				Else
					objRs1.MoveFirst
					Randomize
					For x=1 To 50						
						Val_Rand2 = CStr(CLng((Highest-Lowest + 1) * Rnd + Lowest))	
						If Val_Rand2 < 32767 and Val_Rand > 10 Then Exit For
					Next
					P_TempID = objRs1.Fields("Channel_Pic")
					P_TempID = Left(P_TempID, InStrRev(P_TempID, ".")-1)
				End If					
			Loop While objRs1.EOF = False			
				
		End If

																		'Up till here we have a unique name to be added in the database
																		'Now we need to check whether this name along with the extention
																		'exists in the folder containing the channel images.
				
		set fso = Server.CreateObject("Scripting.FileSystemObject")		'Extracting Picture Extension
		
		fileIndex = GetFileIndexByName(objUpload, "c_pic")		
		PhotoExtension=objUpload.File(fileindex).contentTy  pe
		T_Length=Len(PhotoExtension)
		Ext_Length=InStrRev(PhotoExtension, "/")
		PhotoExtension=Right(PhotoExtension, (T_Length-Ext_Length))
		File_Name=(CStr(Val_Rand2&"."&PhotoExtension))
			
		If (fso.FileExists(Server.Mappath(adFolder+File_Name)  )=True) then	'Changing Picture Name if It exists in the image folder
			Do
				For x=1 To 50
					Val_Rand2=CStr(CLng((Highest-Lowest+1)*Rnd+Lowest))
					If Val_Rand2<32767 and Val_Rand3>10 Then Exit For
				Next					
			Loop While (fso.FileExists(Server.Mappath(adFolder+File_Name)  )=True)

			File_Name=(CStr(Val_Rand2&"."&PhotoExtension))

		End If


		Channel_Folder = objRs2.Fields("channel_folder")
		Call objUpload.File(0).SaveToDisk(server.mappath(Channe  l_Folder), File_Name )
		
		'#################################################  ##################################################  #######################
		
		C_Name = objUpload("C_Name")				'Assigning vales from form to variables.
		C_Desc = objUpload("C_Desc")
		C_ID = Val_Rand
		C_Pic= File_Name



		Set objComm = Server.CreateObject("ADODB.Command")

		objComm.ActiveConnection = strConnect
		objComm.CommandText = "Update_Channels"
		objComm.CommandType = adCmdStoredProc

		Set objParam1 = objComm.CreateParameter("@Channel_ID", adinteger, adParamInput)
		Set objParam2 = objComm.CreateParameter("@Channel_Name", adVarChar, adParamInput, 50)
		Set objParam3 = objComm.CreateParameter("@Channel_Desc", adVarChar, adParamInput, 200)
		Set objParam4 = objComm.CreateParameter("@Channel_Pic", adVarChar, adParamInput, 20)

		objComm.Parameters.Append objParam1
		objComm.Parameters.Append objParam2
		objComm.Parameters.Append objParam3
		objComm.Parameters.Append objParam4

		objComm.Parameters("@Channel_ID") = C_ID
		objComm.Parameters("@Channel_Name") = C_Name
		objComm.Parameters("@Channel_Desc") = C_Desc
		objComm.Parameters("@Channel_Pic") = C_Pic

		Response.write("OK")
		
		'Set objRs = objComm.Execute

		Set objComm = Nothing
		Set objRs = Nothing

		'#################################################  ##################################################  #################
		
		Response.Redirect("channel_confirm.asp")
		
	'End If
End If%>

</body>
</html>


Look for the boldface lines above.

Thanks in advance

CB

Last edited by Shadow Wizard : March 23rd, 2009 at 10:41 AM. Reason: added code tags

Reply With Quote
  #9  
Old March 23rd, 2009, 06:46 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Sorry... A duplicate post.

CB

Reply With Quote
  #10  
Old March 23rd, 2009, 10:48 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
please read my first reply today. it's post #68.
if you can't find it let me know and I'll post it again or send you by private message.
in that post I added "sanity check" code. you don't have this in your code.
add that code (that I have posted) to your existing code and you won't get error.
also, if you have only one file I can't see the reason you insist on using the name..
you should still check to see if any file was uploaded though by checking
the Count and verifying it's more than 0.

last but not least, when posting code in this forum use code tags. it's very simple
to add and it improve readability of the code greatly. if you don't know how to
add code tags please send me PM (private message) and I'll try to explain there.

Reply With Quote
  #11  
Old March 24th, 2009, 01:47 PM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Sorry for not usng the code tags. Will be careful next time. As you said, I've added the sanity check - I was going to ad it later anyway... but still sanity check doesn't solve the problem. The problem is that I receive the Fie not found message even when I choose the file. I've found a way around and want to share it with you. In the function GetFileIndexByName, When I remove the boldface part below, the code works just fine.

Code:
Function GetFileIndexByName(objUpload, strName)
	Dim x, curName, strToSearch
	For x=0 To objUpload.FileCount-1
		curName = LCase(objUpload.File(x).FileName)
		strToSearch = "\" & curName
		If Right(LCase(objUpload(strName)), Len(strToSearch))=strToSearch Then
			GetFileIndexByName = x
			Exit Function
		End If
	Next
	GetFileIndexByName = -1
End Function


But with this change, uploading a picture becomes mandatory. Or I get the same error. Subscript out of range: 'index'

Any help????

CB

Reply With Quote
  #12  
Old March 24th, 2009, 02:11 PM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
OK I got it. I didn't add one part of the Uploading code and that was onSubmit="StoreFileNames(this); return valid(this);" in the form tag....

Thanks for all your efforts. and Great code.

CB
Comments on this post
micky agrees: Thanx for sharing the solution

Reply With Quote
  #13  
Old March 25th, 2009, 02:22 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
removing the GetFileIndexByName = -1 from the function will simply
cause it will return "default" value of 0. there's no point in the function
if you do this.

forgot about StoreFileNames function, sorry - my mistake thanks
for letting us know.

Reply With Quote
  #14  
Old March 25th, 2009, 01:12 PM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 459 Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level)Computer-bot User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 19 h 55 m 38 sec
Reputation Power: 26
Alright there is one more issue. How would I determine whether the file selected is an image. I am using the codeEnd If
Code:
If (objUpload.File(fileIndex).ImageWidth <> -1) Then
Upload the Picture
Else
Generate error message


This code works perfect for .doc and .txt files but doesn't work with .flv, .mpg and other such files. It doesn't show the error. the page says that THE WEB PAGE IS NOT AVAILABLE.

Any ideas????

CB

Reply With Quote
  #15  
Old March 26th, 2009, 10:11 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
IIS has "built in" mechanism that block uploading of any file that is over 200 KB in size.
read post #13 of this thread for more details:
http://forums.aspfree.com/asp-devel...ror-132936.html

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Shadow Uploader - using GetFileIndexByName with non IE browsers


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 



Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap