Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    1,150

    ServerMapPath...errore "necessario oggetto"

    Ciao a tutti, credo che l'errore sia banale, ma non riesco a trovarlo
    Quello che devo fare è leggere in una dir due file (fileavvi1.zip e fileavvi2.zip) e dopo aver verificato se esistono, calcolarne la dimensione.

    Ora il seguente errore

    codice:
    Errore di run-time di Microsoft VBScript (0x800A01A8)
    Necessario oggetto
    /downfileavvifaxx.asp, line 153
    me lo dà sul secondo file (in ordine di controllo) e il file esiste

    Posto il codice, dove la riga evidenziata in rosso è quella incriminata.

    Qualche consiglio?



    codice:
    <%
    	vc_user = session("vc_userprop")
    	Dim strURL
    	Dim con
    	Dim rs
    	Dim strDBPath
    	Dim sql
    	vc_userconn =session("vc_userprop")
    	if vc_userconn =""  then
    		response.redirect "timeoutt.asp"
    	end if
    
    	strURL = Request.ServerVariables("URL")
    
    	%>
    
    <form name="datiform" action="<%= strURL %>" method="get">
    	<table class="tabellavisu" cellspacing="0" cellpadding="0" border="0" width="30%">
    
    	<%
    		' Nome del file da scaricare
    
    		fname = "docuavvi\file\fileavvifaxx\fileavvi1.zip"
    
    		Dim objFile
    		Set objFile = Server.CreateObject ("Scripting.FileSystemObject")
    
    		If objFile.FileExists (Server.MapPath(fname)) Then
    			'	Response.Write "Il file esiste!"
    	%>
    			<tr>
    				<td class="rigatabella" width="10%">
    					Nome File
    				</td>
    				<td class="rigatabella" width="10%">
    					Dimensione (in kb)
    				</td>
    				<td class="rigatabella" width="10%">
    					Download
    				</td>
    			</tr>
    			<tr>
    				<td class="testolabel">
    					fileavvi1.zip
    				</td>
    				<td class="testolabel">
    					<%
    						Function GetFileSize(filepath)
    						Dim fso, f
    						Set fso = Server.CreateObject("Scripting.FileSystemObject")
    						Set f = fso.GetFile(filepath)
    
    						'Response.Write("La dimensione del file è: ")
    						'Response.Write(FormatNumber(f.Size/1024, 2)&" Kb")
    					%>
    					<%=FormatNumber(f.Size/1024, 2)%>
    				</td>
    				<%
    					Set f = nothing
    					Set fso = nothing
    					End Function
    					Dim fname, fpath
    
    					fpath = Server.MapPath(fname)
    					GetFileSize(fpath)
    				%>
    				<td class="testolabel">
    					[img]images/zip.jpg[/img]
    				</td>
    			</tr>
    	<%
    		Else
    			'Response.Write "Il file NON esiste."
    	%>
    			<p class="errori" >
    			Attenzione! Il fileavvi1.zip non esiste	</p>
    			</p>
    	<%
    		End If
    		Set objFile = Nothing
    	%>
    
    
    		<%
    			' Nome del file da scaricare
    
    			fname2 = "docuavvi\file\fileavvifaxx\fileavvi2.zip"
    
    			If objFile.FileExists (Server.MapPath(fname2)) Then  				'	Response.Write "Il file esiste!"
    		%>
    			<tr>
    					<td class="testolabel">
    						fileavvi2.zip
    					</td>
    					<td class="testolabel">
    						<%
    							Function GetFileSize(filepath2)
    							Dim fso, f
    							Set fso = Server.CreateObject("Scripting.FileSystemObject")
    							Set f = fso.GetFile(filepath2)
    
    							'Response.Write("La dimensione del file è: ")
    							'Response.Write(FormatNumber(f.Size/1024, 2)&" Kb")
    						%>
    						<%=FormatNumber(f.Size/1024, 2)%>
    					</td>
    					<%
    						Set f = nothing
    						Set fso = nothing
    						End Function
    						Dim fname2, fpath2
    
    						fpath = Server.MapPath(fname2)
    						GetFileSize(fpath2)
    					%>
    					<td class="testolabel">
    						[img]images/zip.jpg[/img]
    					</td>
    				</tr>
    		<%
    			Else
    				'Response.Write "Il file NON esiste."
    		%>
    				<p class="errori" >
    				Attenzione! Il fileavvi2.zip non esiste	</p>
    				</p>
    		<%
    			End If
    			Set objFile = Nothing
    	%>

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    objFile non c'è visto che lo hai impostato su nothing poche righe più su...

    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    1,150
    Scusate per la disattenzione.
    Ora ho risolto.

    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.