Utilizzo senza problemi un script, per il download forzato dei file. Quando provo a scaricare, sia in locale che in remoto, un file con suffisso .avi o .zip (premetto che se li provo direttamente i file funzionano) ho problemi nel leggerli. Praticamente il windows media player non mi riconosce il file, o meglio il codec con il quale e' stato creato, per i file .zip (che contengono file video.avi) l'archivio risulta corrotto. Ruindi tutti i file vidfeo .avi risultano illeggibili. Questo non avviene con i file: .txt .mp3 ecc...
Ecco il codice creato per avviare il download forzato:
Questa pagina viene processata dal seguente link di un'altra pagina:codice:<% Response.Buffer = True Set Fso = Server.CreateObject("Scripting.FileSystemObject") Set f=fso.getfile(Server.MapPath("file/" & Request.QueryString ("nome_cartella") & "/" & Request.QueryString("nome_file"))) strFileSize=f.size adTypeBinary=1 Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open() objStream.Type = adTypeBinary objStream.LoadFromFile(Server.MapPath("file/" & Request.QueryString ("nome_cartella") & "/" & Request.QueryString("nome_file"))) 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 ".doc" ContentType = "application/msword" Case ".zip" ContentType = "application/zip" ContentType = "application/x-zip-compressed" 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 %>
Penso che il problema sia:
Case ".jpg", "jpeg"
ContentType = "image/jpeg"

Rispondi quotando