Ayuda enviar datos via post a php con comprovacion de boton

Iniciado por marcofbb, 28 Mayo 2010, 01:48 AM

0 Miembros y 1 Visitante están viendo este tema.

marcofbb

Codigo del visual basic:

Código (vb) [Seleccionar]
Const Host As String = "localhost" 'Constante del host

Private Sub Command1_Click()
Winsock1.Close
Winsock1.Connect Host, 80 'Conectamos al host
End Sub

Private Sub Form_Load()
Winsock1.Connect Host, 80 'Conectamos al host
End Sub

Private Sub Timer1_Timer()
If Winsock1.State = sckConnected Then 'Checamos si la conexion es activa o no
    Command1.Enabled = False
Dim Peticion$
Peticion = "POST /archivos/upl2.php HTTP/1.0" & vbCrLf & _
            "Host: " & Host & vbCrLf & _
            "Content-Type: multipart/form-data, boundary=tyoasEdRQLsovS3LUFPBS5Eyy7tOwzil" & vbCrLf & _
            "Content-Length: 197" & vbCrLf & _
            vbCrLf & _
            "--tyoasEdRQLsovS3LUFPBS5Eyy7tOwzil" & vbCrLf & _
            "Content-Disposition: form-data; name='archivo'; filename='imagen.jpg'" & vbCrLf & _
            "Content-Type: image/jpeg" & vbCrLf & _
            vbCrLf & _
            "Soy un jpg modificado!!!" & vbCrLf & _
            "--tyoasEdRQLsovS3LUFPBS5Eyy7tOwzil—"
           
Winsock1.SendData Peticion 'Mandamos la peticion
Else
    Command1.Enabled = True
End If
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Datos$
Winsock1.GetData Datos, vbString, bytesTotal 'Obtenemos los datos
Text2.Text = Datos
End Sub



Codigo html de la web:

Código (html4strict) [Seleccionar]
<form method="POST" enctype="multipart/form-data" action="upl2.php">
<input type="file" name="archivo" size="20">
<input type="submit" value="Enviar" name="send">
<input type="reset" value="Borrar" name="erase">
</form>


Codigo php de la web
Código (php) [Seleccionar]
<link href="style-def.css" rel="stylesheet" type="text/css" />
<?php require('config.php');?>
<a target="_self" border="0" href="<?php $tusitio ?>index.php">Inicio</a> |&nbsp;<a border="0" href="<?php $tusitio ?>gallery.php">Galeria</a> |&nbsp;<a border="0" href="http://entra-ya.com.ar/">Upload by entra-ya</a></br></br>
<?
if($_POST['send']){ ?><?
$prefijo = substr(md5(uniqid(rand())),0,10);
$extensiones=array("html","exe","php","js","asp","PHP","Php","pHp","phP","PHp","PhP","pHP");
$nombre=$_FILES['archivo']['name'];
$tamanio=$_FILES['archivo']['size'];
$tipo=$_FILES['archivo']['type'];
$var = explode(".","$nombre");
$num = count($extensiones);
$valor = $num-1;
$destino =  "tmp/".$prefijo."_".$_FILES["archivo"]['name'].".".$var[1];
for($i=0; $i<=$valor; $i++) {
    if($extensiones[$i] == $var[1]) {
    echo "Tipo de Archivo no admitido";
    exit;
    }
}
if (is_uploaded_file($_FILES['archivo']['tmp_name']))
{
  copy($_FILES['archivo']['tmp_name'],$destino);
  echo "$tusitio$destino";
  echo "</br></br>";
  echo "Datos: </p>";
  echo "Tamaño: $tamanio Bytes</br>";
  echo "Tipo: $tipo";
}
else { echo "Error al subir el archivo"; }
?><? } ?>



El problema es que yo puedo enviar datos al upload y me sube la imagen que mando pero cuando le pongo esto if($_POST['send']){ que para comprobar si apretaste el boton SEND en el html no me deja subir la imagen por visual basic porque no c donde poner send=Enviar en visual basic 6

Espero que se entianda mi duda