Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
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?
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>
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.
já consegue o caminho todo? Então basta quebrar adequadamente a string
Pode ser com SPLIT inicialmente