Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

fabiosc80

[Resolvido] Recuperar apenas o nome do Arquivo de um Input File

Recommended Posts

Tenho um pequeno problema e não consigo chegar em uma solução.

 

Tenho uma página com o seguinte código.

 

<form action="arquivo_request.asp" method="post">

<input type="file" name="arquivo" id="arquivo" />

<input type="submit" value="Gravar" />

</form>

 

 

E ao recuperar na outra página (não é pra fazer upload, apenas quero recuperar o nome do arquivo mesmo), vem com o caminho inteiro e não apenas o nome do arquivo.

Como faço para recuperar apenas o nome do arquivo selecionado?

Compartilhar este post


Link para o post
Compartilhar em outros sites

já consegue o caminho todo? Então basta quebrar adequadamente a string

 

Pode ser com SPLIT inicialmente

Compartilhar este post


Link para o post
Compartilhar em outros sites

olha este exemplo

 

Public function GetFilename(ByVal strGetPath)
    Dim nPos, strFilename
    Dim strDir
    strFilename = ""
        strGetPath = cstr(strGetPath)
        if Not len(strGetPath) = 0 Then
            nPos = InStrRev(strGetPath, "\", Len(strGetPath))
            if nPos > 0 Then
                strFilename = Right(strGetPath, Len(strGetPath) - nPos)
                'Response.Write strFilename
            End if
            nPos = InstrRev(strGetPath, "\", Len(strGetPath) - nPos)
            if nPos > 0 Then
                strDir = Right(strGetPath, Len(strGetPath) - nPos)
            Else
                strDir = ""
            End if 
        End if
        GetFilename = strFilename
    End function

Compartilhar este post


Link para o post
Compartilhar em outros sites

já consegue o caminho todo? Então basta quebrar adequadamente a string

 

Pode ser com SPLIT inicialmente

 

Desculpa Mario, mas não entendi o raciocínio em quebrar o caminho.

 

olha este exemplo

 

Public function GetFilename(ByVal strGetPath)
    Dim nPos, strFilename
    Dim strDir
    strFilename = ""
        strGetPath = cstr(strGetPath)
        if Not len(strGetPath) = 0 Then
            nPos = InStrRev(strGetPath, "\", Len(strGetPath))
            if nPos > 0 Then
                strFilename = Right(strGetPath, Len(strGetPath) - nPos)
                'Response.Write strFilename
            End if
            nPos = InstrRev(strGetPath, "\", Len(strGetPath) - nPos)
            if nPos > 0 Then
                strDir = Right(strGetPath, Len(strGetPath) - nPos)
            Else
                strDir = ""
            End if 
        End if
        GetFilename = strFilename
    End function

Cara valeu.

Era exatamente isso oque eu precisava.

Valeu mesmo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.