Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Download nascosto

  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2001
    Messaggi
    113

    Download nascosto

    Ciao a tutti ragazzi, ho un piccolo problema.

    In un'area riservata ho dei file messi in un'area di download.
    Quando l'utente accede all'area riservata, se passa sopra con il mouse ovviamente può avere la path che identifica il file da scaricare e, volendo, farlo scaricare a chi vuole.

    Per ovviare a questo ho trovato online un file denominato download.asp che nasconde la directory.

    -----------------------------------
    <%
    Dim objStream, strFileName
    strFileName = Request.QueryString("file")
    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Type = 1 ' adTypeBinary
    objStream.Open
    objStream.LoadFromFile Server.MapPath("DIRECTORY_DOWNLOAD/" & strFileName)
    ' Istruiamo il browser sul tipo di file
    Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
    Response.ContentType = "application/octet-stream"
    Response.BinaryWrite objStream.Read
    objStream.Close
    Set objStream = Nothing
    %>
    -----------------------------------

    Il problema è che se ci sono file più grandi di 800k va in errore e non mi permette più il download del file.
    Avete qualche escamotage per risolvere il problema?

    Grazie a tutti

  2. #2
    Ciao,

    io uso questo codice che permette lo scarico di file anche di 70/80Mb, solo che appesantisce il processore da paura:
    Codice PHP:
    '8***********************************************8
    Jason Withrow - For ASP101 July 2001
    ' This page forces the save as dialogue to prevent
    files from being opened in the browser.
    '
    [email]jwithrow@mediaone.net[/email]
    '8***********************************************8
                    
    Response.Buffer = True

        strFilePath = Server.MapPath(PercorsoFile)
        Set oFso = CreateObject("Scripting.FileSystemObject")
        Set oFile = oFso.GetFile(strFilePath)
        strFileName = UCase(oFile.Name)
        strFileSize = CLNG(oFile.size)
        Set oFile = Nothing
        Set oFso = Nothing

    end add

    Const adTypeBinary 1

    'strFilePath = Request.QueryString("File")
    '
    strFileSize Request.QueryString("Size")
    'strFileName = Request.QueryString("Name")

    Response.Clear

    '
    8*******************************8
    ' Requires MDAC 2.5 to be stable
    I recommend MDAC 2.6 or 2.7
    '8*******************************8
    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open
    objStream.Type = adTypeBinary
    objStream.LoadFromFile strFilePath

    strFileType = lcase(Right(strFileName, 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"
                
    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.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
        Response.AddHeader "Content-Length", strFileSize
        ' 
    In a Perfect WorldYour Client would also have UTF-as the default 
        
    ' In Their Browser
        Response.Charset = "UTF-8"
        Response.ContentType = ContentType
        
        Do While Not objStream.EOS
            Response.BinaryWrite objStream.Read(1024)
            Response.Flush
        Loop

    objStream.Close
    Set objStream = Nothing 
    fulvio

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.