Salve a tutti
utilizzo questo script per il download forzato dei file da una certa cartella.
Sui pdf ed altri formati non mi da problemicodice:'inizio download forzato file Response.Buffer = True Set Fso = Server.CreateObject("Scripting.FileSystemObject") response.write url Set f=fso.getfile(Server.MapPath(url)) strFileSize=f.size adTypeBinary=1 Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open() objStream.Type = adTypeBinary objStream.LoadFromFile(Server.MapPath(url)) nomefile = request.querystring ("nome_file") tipologia = lcase(Right(nomefile, 4)) Select Case tipologia Case ".asf" ContentType = "video/x-ms-asf" Case ".avi" ContentType = "video/avi" Case ".pdf" ContentType = "application/acreader" Case ".xls" ContentType = "application/vnd.ms-excel" Case ".gif" ContentType = "image/gif" Case ".jpg", "jpeg" ContentType = "image/jpeg" Case ".wav" ContentType = "audio/wav" Case ".mp3" ContentType = "audio/mpeg3" Case ".mpg", "mpeg" ContentType = "video/mpeg" Case ".rtf" ContentType = "application/rtf" Case ".htm", "html" ContentType = "text/html" Case ".asp" ContentType = "text/asp" Case Else 'Handle All Other Files ContentType = "application/octet-stream" End Select Response.ContentType = ContentType Response.AddHeader "Content-Disposition", "attachment; filename=" & nomefile Response.AddHeader "Content-Length", strFileSize Response.Charset = "UTF-8" Response.BinaryWrite(objStream.Read) Response.Flush objStream.Close() Set objStream = Nothing ' fine download forzato file end if %>
I file che hanno invecie estensione .doc .xls .zip vengono scaricati con una codifica errata.
Di conseguenza una volta downloadati non sono leggibili.
Nella pagina non ho parti di codice html, ma ho alcuni if che riguardano la sessione e le credenziali dell'utente.
Cosa può essere che mi crea questo problema ?
Grazie

Rispondi quotando