Ciao a tutti, ho bisogno di un aiuto.
Con questo script ASP esporto da un db mysql i dati di una tabella in formato XML e poi li trasformo in formato CSV (tramite XSL) e forzo il download del file.
Il problema è che tutto funziona bene tranne quando il nome del file da trasformare è pippo.xml in pippo.csv (cioè la condizione 2): invece di scaricare correttamente il file pippo.csv lo script propone come download il nome della pagina ASP che esegue lo script.
Sapete dirmi che cosa sbaglio?
Grazie.
codice:<% strA = request.form("A") ''' ASSEGNO IL NOME DEL FILE XML if strA = 0 THEN filename = "pluto.xml" end if if strA = 1 THEN filename = "paperino.xml" end if if strA = 2 THEN filename = "pippo.xml" end if Set xmlDoc = CreateObject("MSXML2.DOMDocument.4.0") Set xslDoc = CreateObject("MSXML2.DOMDocument.4.0") %> <% '''QUERY SU TABELLA DA ESPORTARE SQL = "SELECT * FROM tbl_txt " Set Rs = CreateObject("ADODB.Recordset") Rs.Open SQL, cn if not Rs.eof then '''SALVATAGGIO IN FORMATO XML Rs.Save xmlDoc, 1 xmlDoc.Save Server.MapPath("_XML/" & filename & "") end if Rs.Close Set Rs = Nothing %> <% Set oDOM = CreateObject("MSXML2.DOMDocument.4.0") oDOM.async = False oDOM.Load Server.Mappath("_XML/" & filename & "") Set oXSL = CreateObject("MSXML2.DOMDocument.4.0") oXSL.async = False '''TRASFORMO IL FILE XML IN CSV TRAMITE XSL oXSL.Load Server.Mappath("_XML/_include/Trasform_csv.xsl") strTransform = oDOM.transformNode(oXSL) Set fso = CreateObject("Scripting.FileSystemObject") '''ASSEGNO IL NOME AL FILE CSV if strA = 0 THEN strPath = Server.Mappath("_XML/pluto.csv") end if if strA = 1 THEN strPath = Server.Mappath("_XML/paperino.csv") end if if strA = 2 THEN strPath = Server.Mappath("_XML/pippo.csv") end if Set file = fso.opentextfile(strPath, 2, True) file.write strTransform file.Close Set file = Nothing Set fso = Nothing Set oDOM = Nothing Set oXML = Nothing Set oXSL = Nothing cn.Close() Set cn = Nothing '''DOWNLOAD FORZATO Set objStream = Server.CreateObject("ADODB.Stream") objStream.Type = 1 objStream.Open objStream.LoadFromFile strPath if strA = 0 THEN Response.AddHeader "Content-Disposition", "attachment; filename=pluto.csv" end if if strA = 1 THEN Response.AddHeader "Content-Disposition", "attachment; filename=paperino.csv" end if if strA = 2 THEN Response.AddHeader "Content-Disposition", "attachment; filename=pippo.csv" end if Response.ContentType = "application/octet-stream" Response.BinaryWrite objStream.Read Response.Flush objStream.Close Set objStream = Nothing %>

Rispondi quotando
