Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    collegamento relativo immagine

    Utilizzo questo codice in risposta ad un form con un seplice campo file per farne l'upload nella cartella "img"

    E' possibile recuperare solo il nome del file
    es. http://www.miodominio.it/img/foto.jpg -------> foto.jpg

    Oppure la posizione rispetto ad un file...

    Grazie
    Parafarmacia online, tantissimi prodotti tutti in un click

  2. #2

    Ecco il codice

    <%

    percorso = "img/"

    ByteRicevuti = Request.TotalBytes

    if ByteRicevuti > 0 then
    DatiRicevuti = Request.BinaryRead(ByteRicevuti)
    For i = 1 To lenB(DatiRicevuti)
    FileBinario = FileBinario & chr(ascB(midB(DatiRicevuti,i,1)))
    Next
    FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1)
    ArrPezzi = split(FileBinario,FirmaFile)

    for item = 1 to ubound(ArrPezzi)-1
    Inizio = instr(ArrPezzi(item),"" & vbCrLf & "" & vbCrLf)
    Intestazione = left(ArrPezzi(item),Inizio-1)
    Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf)
    ContenutoFile = mid(ArrPezzi(item),Inizio,len(ArrPezzi(item))-Inizio-1)

    ' Recupero i campi se sono compilati
    if instr(Intestazione,"testo1") > 0 then
    testo1 = ContenutoFile

    dim strTesto
    strTesto = ContenutoFile


    end if


    if instr(Intestazione,"file1") > 0 then
    i = instr(Intestazione,"filename=")
    j = instr(i + 10,Intestazione,chr(34))
    NomeUpload = mid(Intestazione,i + 10,j-i-10)
    i = instrRev(NomeUpload,"\")
    if i<>0 then
    NomeFile = mid(NomeUpload,i + 1)
    else
    NomeFile = NomeUpload
    end if
    if i<>0 then
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Upload1 = True
    DimensioneFile1 = len(ContenutoFile)
    EstensioneFile1 = right(ContenutoFile,3)
    NomeFile1 = NomeFile
    Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile1), True, False)
    textStream.Write ContenutoFile
    textStream.Close
    Set textStream = Nothing
    Set FSO = Nothing
    end if
    end if


    next






    If Upload1 = true then
    Response.Write "
    Il file caricato è di " & DimensioneFile1*0.001 & "kb"
    Response.Write "
    Verrai reinderizzato al pannello di gestione entro pochi secondi"
    response.redirect("modifica.asp")

    else

    response.write "NO"

    End If


    End if
    %>
    Parafarmacia online, tantissimi prodotti tutti in un click

  3. #3
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    In NomeFile1 hai il nome del file.

    Roby

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.