Ver Mensaje Individual
  #1  
Antiguo 19-03-2008
recargador recargador is offline
Registrado
 
Registrado: feb 2008
Posts: 5
Reputación: 0
recargador Va por buen camino
Subir por post un archivo a un sitio web usando winsock

Bueno si o si necesitaba subir un archivo a un sitio web no usando ftp y no usando indy ni nado solo winsock asi que tengo un formulario en php en mi pagina web un form para subirlo y me fije en un envio del intenet explorer y
copie la cabecera y le sume el archivo el problema que tengo es que el 'Content-Length:50362' me fije por google y no entendi bien se que tengo que poner el tamano de los datos que intento enviar en este ejemplo el tamano del archivo es de 50000 lo que no se de que son los 362 restante si de la cabecera o lo que acompana al archivo en el cuerpo del mensaje si alguien sabe se lo agradeceria
Código PHP:

boundary 
:= '---------------------------123456789';
strdata:='POST /subearchivo.php HTTP/1.1'#13#10 +
'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/xaml+xml,'+' application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*'#13#10 +
'Referer: http://www.hosting.com/index.php'#13#10 +
'Accept-Language: es-ar'#13#10 +
'Content-Type: multipart/form-data; boundary=' boundary #13#10 +
'UA-CPU: x86'#13#10 +
'Accept-Encoding: gzip, deflate'#13#10 +
'User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; MEGAUPLOAD 2.0)'#13#10 +
'Host: www.hosting.com'#13#10 +
'Content-Length:50362'+#13#10 ;
    
strData := strData '--' boundary #13#10 + 'Content-Disposition: form-data; name=""MAX_FILE_SIZE""' + #13#10#13#10 + '1000' + #13#10;

    
strData := strData '--' boundary #13#10 + 'Content-Disposition: form-data; name="' + n + '"; filename="' + v + '"' + #13#10;

    
strData := strData 'Content-Type: application/x-zip-compressed'+#13#10#13#10;

      
ms := TMemoryStream.Create;
      try
        
ms.LoadFromFile(v) ;
        
ss := TStringStream.Create('') ;
        try
          
ss.CopyFrom(msms.Size) ;

          
strData := strData ss.DataString #13#10;

        
finally
          ss
.Free;
        
end;   
      
finally   
        ms
.Free;
      
end;


    
strData := strData '--' boundary '--'#13#10; // FOOTER


  
strData := strData #0;


  
ClientSocket := TClientSocket.Create;

  
ClientSocket.Connect('hosting.com'80);

  
ClientSocket.SendString(strData);

  
ClientSocket.Idle(0);

  
MessageBox(0pchar(ClientSocket.ReceiveString), 'fidel'0);

  
ClientSocket.Disconnect;

  
ClientSocket.Free
Responder Con Cita