Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente bannato
    Registrato dal
    Nov 2004
    Messaggi
    241

    salva file sul client che funziona male

    codice:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
        FileName = request.QueryString("file")
    	path = request.QueryString("path")
    
    	strFileType = lcase(Right(FileName, 4))
    	
    	' Feel Free to Add Your Own Content-Types Here
    	Select Case strFileType
    	Case ".asf"
    	ContentType = "video/x-ms-asf"
    	Case ".avi"
    	ContentType = "video/avi"
    	Case ".doc"
    	ContentType = "application/msword"
    	Case ".zip"
    	ContentType = "application/zip"
    	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 = "application/octet-stream"
        Response.AddHeader "content-disposition", "attachment; filename =" & filename
        Set Stream = Server.CreateObject("ADODB.Stream")
            Stream.Open
            Stream.LoadFromFile Server.MapPath(path & Filename)
                Conents = Stream.ReadText
                Response.BinaryWrite Contents
            Stream.Close
        Set Stream = Nothing
    %>
    lo richiamo con
    codice:
    Ciao.Doc
    Sembra funzionare bene, salva il file nella dimensione giusta ma quando provo ad aprirlo mi da problemi
    se provo con un'immagine non mi fa nemmeno l'anteprima..

    il codice l'ho trovato con google e sembra funzionare, ma quando provo ad aprire il file mi da questo problema

  2. #2
    Utente di HTML.it L'avatar di viki1967
    Registrato dal
    Feb 2003
    Messaggi
    1,757
    codice:
    <%@ Language = "VBScript" %>
    <% option explicit
    
    Dim  fileSize , fileName , FileFullPath
    'FileSize=Dimensioni del file da scaricare in BYTES
    'FileName=Nome da dare al file che scarico
    'FileFullPath=Nome e percorso del file da scaricare
    
    fileFullPath = "c:\nomefile.ext"		' Inserire qui il fullPath del file da downloadare.
    
    
    Dim fso, fileObj
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fileObj = fso.GetFile(FileFullPath) 
    
    fileSize = fileObj.size  
    fileName = fileObj.name
    
    
    Set fileObj = nothing
    Set fso = nothing
    
    
    Response.Clear
    
    Dim adoStream
    Set adoStream = Server.CreateObject("ADODB.Stream")
    adoStream.Open()
    adoStream.Type = 1
    adoStream.LoadFromFile fileFullPath
    Response.AddHeader "Content-Disposition", "attachment;filename=" & fileName
    Response.AddHeader "Content-Length", fileSize
    Response.ContentType = "application/octet-stream"
    Response.BinaryWrite( adoStream.Read() )
    adoStream.Close
    Set adoStream = Nothing
    
    
    %>
    E' testato e funzionante.
    Basta personalizzarlo inserendo il valore a piacere della variabilefileFullPath.
    A S P : tutto il resto è noia...
    L I N U X : forse mi "converto"...

  3. #3
    Utente bannato
    Registrato dal
    Nov 2004
    Messaggi
    241
    grazie

  4. #4
    Utente di HTML.it L'avatar di viki1967
    Registrato dal
    Feb 2003
    Messaggi
    1,757
    Originariamente inviato da s0r4
    grazie
    Prego!
    A S P : tutto il resto è noia...
    L I N U X : forse mi "converto"...

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.