Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Download Forzato

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    262

    Download Forzato

    Ciao,
    ho guardato tutti i codici che ho trovato sul Download ed alla fine ho preso quello di "optime". mi da errore nella riga: objStream.LoadFromFile strFilePath con l'errore: File could not be opened.

    vi posto il codice:
    codice:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <link rel=stylesheet href="style.css" type="text/css">
    <TITLE>Centro Trascrizioni Stampa Braille e Ingrandita</TITLE>
    </HEAD>
    <BODY>
    
    DOWNLOAD FORZATO 
    
    
    
    
    
    
    <%
    dim sDownload
    sDownload = Request.QueryString("do")
    if sDownload = "si" then
    	Response.Buffer = True
    	Dim strFilePath, strFileSize, strFileName
    	Dim oFso, oFile
    	'application("PATH_CTB")  = "c:\Inetpub\wwwroot\CTB_FILES\"
    	'sCodice = "SUNA40600001"
    	PATH_FILE =  application("PATH_CTB") & "SUNA40600001"   'sCodice
    	strFilePath = PATH_FILE + "\" 
    	'Response.Write (strFilePath)
    	Set oFso = CreateObject("Scripting.FileSystemObject")
    	Set oFile = oFso.GetFile(strFilePath+ "P2200055.JPG")
    	Response.Write (oFso.GetFile(strFilePath+ "P2200055.JPG"))
    	strFileName = "P2200055.JPG"
    	strFileSize = CLNG(oFile.size)
    	Set oFile = Nothing
    	Set oFso = Nothing
    	Const adTypeBinary = 1
    	'Response.Clear
    	Set objStream = Server.CreateObject("ADODB.Stream")
    	objStream.Open
    	objStream.Type = adTypeBinary
    	'Response.End 
    	objStream.LoadFromFile strFilePath
    	strFileType = lcase(Right(strFileName, 4))
    	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
    	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
    else%>
    <a href ="AAA6.asp?do='si'">Download</a><%
    end if%>
    </BODY>
    </HTML>
    Dove sbaglio? Inoltr devo salvare tutti i file senza distinzione di estensione.

    Grazie mille

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Fatti stampare strFilePath

    Roby

  3. #3
    ciao minny71 ho la soluzione per te.. volevo inviartela via mail ma non hai dato il consenso... fammi sapere se ti serve ancora. rispondi a questo messaggio.ciao...

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    262
    Ciao criptus17,
    ho risolto. , grazie per la tua mail

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.