Aprire una file doc all'apertura pagina

giovedì 21 aprile 2011 - 21.54

tigre Profilo | Junior Member

ho un link che manda il nome del file da aprire ad una pagina apri.asp
dopo aver aperto la pagina, salvato un record mi deve aprire (o salvare) il file .doc-
tipico download.

come devo fare???

alx_81 Profilo | Guru

>ho un link che manda il nome del file da aprire ad una pagina
>apri.asp
>dopo aver aperto la pagina, salvato un record mi deve aprire
>(o salvare) il file .doc-
>tipico download.
>
>come devo fare???
Ciao, segui questo link:
http://www.bellaonline.com/articles/art46052.asp

--
Alessandro Alpi | SQL Server MVP
MCP|MCITP|MCTS|MCT

http://www.alessandroalpi.net
http://blogs.dotnethell.it/suxstellino
http://mvp.support.microsoft.com/profile/Alessandro.Alpi

tigre Profilo | Junior Member

grazie,
ho provato cosi:
il link va alla pagina apri_file.asp , cosi:

<a href="apri_file.asp?nome=<%="file.doc"%>" target="_blank">

..APRI_FILE.ASP

<%'=======================
'Define the names of your functions
'=======================
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
'=======================
'Get the actual file name from the URL that is passed to the browser
'=======================
FileName = request.querystring("nome") 'Get the name from the URL
'=======================
'GIVE AN ERROR MESSAGE IF THE URL IS EMPTY
'=======================
if FileName = "" Then
response.write "Filename Not specified."
response.end
end if
'=======================
'prevent access to certain files
'=======================
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
select case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
response.write "You cannot access these file types."
response.end
end select
'=======================
'Start the download process if all is good
'=======================
response.clear
response.contentType = "application/octet-stream"
response.addheader "content-disposition", "attachment; filename=" & FileName
set stream = server.CreateObject("ADODB.Stream")
stream.type = adTypeBinary
stream.open
stream.LoadFromFile Server.MapPath("/MANG/U.O.3/") & FileName
while not stream.EOS
response.BinaryWrite Stream.Read(1024 * 64)
wend
stream.Close
Set stream = Nothing
response.Flush
response.End
%>
---------------------------------------
PERo mi da questo errore:
mi apre il caricamento della pagina,
ma mi dice::Impossibile scaricare il file APRI_FILE.ASP da 127.0.0.1
impossibile aprire il sito internet.....

alx_81 Profilo | Guru

>grazie,
>ho provato cosi:
hai provato a vedere se:
- il file esiste nel percorso prodotto (prova a scriverlo full)
- hai i permessi per leggerlo tramite utente IUSR


--
Alessandro Alpi | SQL Server MVP
MCP|MCITP|MCTS|MCT

http://www.alessandroalpi.net
http://blogs.dotnethell.it/suxstellino
http://mvp.support.microsoft.com/profile/Alessandro.Alpi
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5