Ir para conteúdo

POWERED BY:

Arquivado

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

Ivan.Teles

Erro em Upload com 10 Imagens

Recommended Posts

Bom pessoal, eu aqui de novo.

 

Adaptei um script de upload pra enviar 10 imagens, só que quando se seleciona mais de 06 imagen da erro na linha:

 

RequestBin = Request.BinaryRead(byteCount)

Se eu enviar até 05 imagens funciona numa boa, seja elas de 01 a 05 ou de 06 a 10, porém se eu tentar enviar 10 ele da erro:

 

Como resolver??

 

Script completo da página

<!-- #include file="upload.asp" -->
<!-- #include file="banco.asp" -->
<%

' Chamando Funções, que fazem o Upload funcionar
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin

titulo = UploadRequest.Item("titulo").Item("Value")
descricao = UploadRequest.Item("descricao").Item("Value")
recupera = UploadRequest.Item("evento").Item("Value")

If recupera = "" Then
response.Write("<script>alert('O campo data não pode está vazio.');history.go(-1)</script>")
response.End()
else
data_conv1 = split(recupera,"/") 'funcao utilizada para criar um vetor delimitado po "/" 
data_corr1 = data_conv1(1)&"/"&data_conv1(0)&"/"&data_conv1(2) 'reorganiza data para o formato dd/mm/yy 
End if

If titulo = "" Then
response.Write("<script>alert('O campo título não pode está vazio.');history.go(-1)</script>")
response.End()
End if

If descricao = "" Then
response.Write("<script>alert('O campo descrição não pode está vazio.');history.go(-1)</script>")
response.End()
End if


' Tipo de arquivo que esta sendo enviado
tipo_foto = UploadRequest.Item("foto01").Item("ContentType")
tipo_foto2 = UploadRequest.Item("foto02").Item("ContentType")
tipo_foto3 = UploadRequest.Item("foto03").Item("ContentType")
tipo_foto4 = UploadRequest.Item("foto04").Item("ContentType")
tipo_foto5 = UploadRequest.Item("foto05").Item("ContentType")
tipo_foto6 = UploadRequest.Item("foto06").Item("ContentType")
tipo_foto7 = UploadRequest.Item("foto07").Item("ContentType")
tipo_foto8 = UploadRequest.Item("foto08").Item("ContentType")
tipo_foto9 = UploadRequest.Item("foto09").Item("ContentType")
tipo_foto10 = UploadRequest.Item("foto010").Item("ContentType")

' Caminho completo dos arquivos enviados
caminho_foto = UploadRequest.Item("foto01").Item("FileName")
caminho_foto2 = UploadRequest.Item("foto02").Item("FileName")
caminho_foto3 = UploadRequest.Item("foto03").Item("FileName")
caminho_foto4 = UploadRequest.Item("foto04").Item("FileName")
caminho_foto5 = UploadRequest.Item("foto05").Item("FileName")
caminho_foto6 = UploadRequest.Item("foto06").Item("FileName")
caminho_foto7 = UploadRequest.Item("foto07").Item("FileName")
caminho_foto8 = UploadRequest.Item("foto08").Item("FileName")
caminho_foto9 = UploadRequest.Item("foto09").Item("FileName")
caminho_foto10 = UploadRequest.Item("foto010").Item("FileName")

' Nome dos arquivos enviados
nome_foto = Right(caminho_foto,Len(caminho_foto)-InstrRev(caminho_foto,"\"))
nome_foto2 = Right(caminho_foto2,Len(caminho_foto2)-InstrRev(caminho_foto2,"\"))
nome_foto3 = Right(caminho_foto3,Len(caminho_foto3)-InstrRev(caminho_foto3,"\"))
nome_foto4 = Right(caminho_foto4,Len(caminho_foto4)-InstrRev(caminho_foto4,"\"))
nome_foto5 = Right(caminho_foto5,Len(caminho_foto5)-InstrRev(caminho_foto5,"\"))
nome_foto6 = Right(caminho_foto6,Len(caminho_foto6)-InstrRev(caminho_foto6,"\"))
nome_foto7 = Right(caminho_foto7,Len(caminho_foto7)-InstrRev(caminho_foto7,"\"))
nome_foto8 = Right(caminho_foto8,Len(caminho_foto8)-InstrRev(caminho_foto8,"\"))
nome_foto9 = Right(caminho_foto9,Len(caminho_foto9)-InstrRev(caminho_foto9,"\"))
nome_foto10 = Right(caminho_foto10,Len(caminho_foto10)-InstrRev(caminho_foto10,"\"))

rndNumber=INT((RND*9999999999)+1)
rdn = rndNumber
Set objFS = Server.CreateObject("Scripting.FileSystemObject")
If objFS.FileExists( Server.mappath("anexos/" & nome_foto)) Then
nome_foto = rdn & nome_foto

Else If objFS.FileExists( Server.mappath("anexos/" & nome_foto2)) Then
nome_foto2 = rdn & nome_foto2

Else If objFS.FileExists( Server.mappath("anexos/" & nome_foto3)) Then
nome_foto3 = rdn & nome_foto3

Else If objFS.FileExists( Server.mappath("anexos/" & nome_foto4)) Then
nome_foto4 = rdn & nome_foto4

Else If objFS.FileExists( Server.mappath("anexos/" & nome_foto5)) Then
nome_foto5 = rdn & nome_foto5

Else If objFS.FileExists( Server.mappath("anexos/" & nome_foto6)) Then
nome_foto6 = rdn & nome_foto6

Else If objFS.FileExists( Server.mappath("anexos/" & nome_foto7)) Then
nome_foto7 = rdn & nome_foto7

else If objFS.FileExists( Server.mappath("anexos/" & nome_foto8)) Then
nome_foto8 = rdn & nome_foto8

else If objFS.FileExists( Server.mappath("anexos/" & nome_foto9)) Then
nome_foto9 = rdn & nome_foto9

else If objFS.FileExists( Server.mappath("anexos/" & nome_foto10)) Then
nome_foto10 = rdn & nome_foto10

End if
End if
End if
End if
End if
End if
End if
End if
End if
End if

' Conteudo binario dos arquivos enviados
foto = UploadRequest.Item("foto01").Item("Value")
foto2 = UploadRequest.Item("foto02").Item("Value")
foto3 = UploadRequest.Item("foto03").Item("Value")
foto4 = UploadRequest.Item("foto04").Item("Value")
foto5 = UploadRequest.Item("foto05").Item("Value")
foto6 = UploadRequest.Item("foto06").Item("Value")
foto7 = UploadRequest.Item("foto07").Item("Value")
foto8 = UploadRequest.Item("foto08").Item("Value")
foto9 = UploadRequest.Item("foto09").Item("Value")
foto10 = UploadRequest.Item("foto010").Item("Value")

' pasta onde as imagens serao guardadas
pasta = Server.MapPath("anexos/")
nome_foto = "/"&nome_foto
nome_foto2 = "/"&nome_foto2
nome_foto3 = "/"&nome_foto3
nome_foto4 = "/"&nome_foto4
nome_foto5 = "/"&nome_foto5
nome_foto6 = "/"&nome_foto6
nome_foto7 = "/"&nome_foto7
nome_foto8 = "/"&nome_foto8
nome_foto9 = "/"&nome_foto9
nome_foto10 = "/"&nome_foto10

' pasta + nome dos arquivos
cfoto = "anexos" + nome_foto
cfoto2 = "anexos" + nome_foto2
cfoto3 = "anexos" + nome_foto3
cfoto4 = "anexos" + nome_foto4
cfoto5 = "anexos" + nome_foto5
cfoto6 = "anexos" + nome_foto6
cfoto7 = "anexos" + nome_foto7
cfoto8 = "anexos" + nome_foto8
cfoto9 = "anexos" + nome_foto9
cfoto10 = "anexos" + nome_foto10

' Fazendo o Upload do arquivo selecionado
if foto <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto)
For i = 1 to LenB(foto)
MyFile.Write chr(AscB(MidB(foto,i,1)))
Next
MyFile.Close
end if

if foto2 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto2)
For i = 1 to LenB(foto2)
MyFile.Write chr(AscB(MidB(foto2,i,1)))
Next
MyFile.Close
end if

if foto3 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto3)
For i = 1 to LenB(foto3)
MyFile.Write chr(AscB(MidB(foto3,i,1)))
Next
MyFile.Close
end if

if foto4 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto4)
For i = 1 to LenB(foto4)
MyFile.Write chr(AscB(MidB(foto4,i,1)))
Next
MyFile.Close
end if

if foto5 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto5)
For i = 1 to LenB(foto5)
MyFile.Write chr(AscB(MidB(foto5,i,1)))
Next
MyFile.Close
end if

if foto6 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto6)
For i = 1 to LenB(foto6)
MyFile.Write chr(AscB(MidB(foto6,i,1)))
Next
MyFile.Close
end if

if foto7 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto7)
For i = 1 to LenB(foto7)
MyFile.Write chr(AscB(MidB(foto7,i,1)))
Next
MyFile.Close
end if

if foto8 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto8)
For i = 1 to LenB(foto8)
MyFile.Write chr(AscB(MidB(foto8,i,1)))
Next
MyFile.Close
end if

if foto9 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto9)
For i = 1 to LenB(foto9)
MyFile.Write chr(AscB(MidB(foto9,i,1)))
Next
MyFile.Close
end if

if foto10 <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto10)
For i = 1 to LenB(foto10)
MyFile.Write chr(AscB(MidB(foto10,i,1)))
Next
MyFile.Close
end if

ins = "INSERT INTO eventos (data, titulo, descricao, foto01, foto02, foto03, foto04, foto05, foto06, foto07, foto08, foto09, foto010) values (#"&data_corr1&"#,'"&titulo&"','"&descricao&"','"& replace(nome_foto,"/", "") &"','"& replace(nome_foto2,"/", "") &"','"& replace(nome_foto3,"/", "") &"','"& replace(nome_foto4,"/", "") &"','"& replace(nome_foto5,"/", "")  &"','"& replace(nome_foto6,"/", "") &"','"& replace(nome_foto7,"/", "") &"','"& replace(nome_foto8,"/", "") &"','"& replace(nome_foto9,"/", "") &"','"& replace(nome_foto10,"/", "") &"')"
conconexao.execute(ins)
response.write("<script>alert('Dados cadastrado com sucesso!!!');location.href='cadastrar_evento.asp'</script>")

%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

o que tem nesta pagina upload.asp ??? posta para que possamos ver mostra o erro que da... pois não temos o arquivo completo para testar... fica dificiu assim... vamos ficar no aguardo

Compartilhar este post


Link para o post
Compartilhar em outros sites

Lembrando que o erro so ocorre no server on line, na minha maquina localhost funciona numa boa.

 

Página Upload.asp

 

<%
' Upload Sem componentes ---------------------------------------
Sub BuildUploadRequest(RequestBin)
	on error resume next

	PosBeg = 1
	PosEnd = InStrB(PosBeg, RequestBin, getByteString(Chr(13)))
	boundary = MidB(RequestBin, PosBeg, PosEnd - PosBeg)
	BoundaryPos = InStrB(1, RequestBin, boundary)

	Do Until (BoundaryPos = InStrB(RequestBin, boundary & getByteString("--")))

  Dim UploadControl
  Set UploadControl = CreateObject("Scripting.Dictionary")
  Pos = InStrB(BoundaryPos, RequestBin, getByteString("Content-Disposition"))
  Pos = InStrB(Pos, RequestBin, getByteString("name="))
  PosBeg = Pos + 6
  PosEnd = InStrB(PosBeg, RequestBin, getByteString(Chr(34)))
  Name = getString(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
  PosFile = InStrB(BoundaryPos, RequestBin, getByteString("filename="))
  PosBound = InStrB(PosEnd, RequestBin, boundary)

  If PosFile <> 0 And (PosFile < PosBound) Then
	  PosBeg = PosFile + 10
	  PosEnd = InStrB(PosBeg, RequestBin, getByteString(Chr(34)))
	  FileName = getString(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
	  UploadControl.Add "FileName", FileName
	  Pos = InStrB(PosEnd, RequestBin, getByteString("Content-Type:"))
	  PosBeg = Pos + 14
	  PosEnd = InStrB(PosBeg, RequestBin, getByteString(Chr(13)))
	  ContentType = getString(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
	  UploadControl.Add "ContentType", ContentType
	  PosBeg = PosEnd + 4
	  PosEnd = InStrB(PosBeg, RequestBin, boundary) - 2
	  Value = MidB(RequestBin, PosBeg, PosEnd - PosBeg)
  Else
	  Pos = InStrB(Pos, RequestBin, getByteString(Chr(13)))
	  PosBeg = Pos + 4
	  PosEnd = InStrB(PosBeg, RequestBin, boundary) - 2
	  Value = getString(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
  End If

  UploadControl.Add "Value", Value
  UploadRequest.Add Name, UploadControl
  BoundaryPos = InStrB(BoundaryPos + LenB(boundary), RequestBin, boundary)
	Loop
End Sub

Function getByteString(StringStr)
	For i = 1 To Len(StringStr)
  Char = Mid(StringStr, i, 1)
  getByteString = getByteString & ChrB(AscB(Char))
	Next
End Function

Function getString(StringBin)
	getString = ""
	For intCount = 1 To LenB(StringBin)
  getString = getString & Chr(AscB(MidB(StringBin, intCount, 1)))
	Next
End Function

' Fim upload sem Componentes -----------------------------------------
%>

 

Erro:

Objeto Request erro 'ASP 0104 : 80004005' 

Operação não permitida 

/cad_evento.asp, line 18

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.