PDA

View Full Version : File Submit with HTTP.Submit?



Vancete
02-19-2009, 08:08 AM
Hi!
I have this PHP file in my server...


<?
$cadenatexto = $_POST["cadenatexto"];
$archivo = 'archivo.htm';
$fp = fopen($archivo, "w");
$write = fwrite($fp, $cadenatexto);
fclose($fp);
$nombre_archivo = $HTTP_POST_FILES['userfile']['name'];
$tipo_archivo = $HTTP_POST_FILES['userfile']['type'];
$tamano_archivo = $HTTP_POST_FILES['userfile']['size'];
if (!((strpos($tipo_archivo, "gif") || strpos($tipo_archivo, "jpeg")))) {
echo "La extensión o el tamaño de los archivos no es correcta. <br><br><table><tr><td><li>Se permiten archivos .gif o .jpg<br><li>se permiten archivos de 100 Kb máximo.</td></tr></table>";
}else{
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $nombre_archivo)){
echo "El archivo ha sido cargado correctamente.";
}else{
echo "Ocurrió algún error al subir el fichero. No pudo guardarse.";
}
}
?>

I can use HTTP.Submit for set the cadenatexto but i can't use userfile for upload a file...
How can I do this?

Greetings! ;) (And sorry for my english...)

Ulrich
02-19-2009, 04:44 PM
It is not possible - you will need multipart/formdata encoding, which is not currently provided by the HTTP actions. But you could use a web object to send the file to the server, using a local HTML document. Or just use FTP...

Ulrich

Imagine Programming
02-19-2009, 04:55 PM
It is not possible - you will need multipart/formdata encoding, which is not currently provided by the HTTP actions. But you could use a web object to send the file to the server, using a local HTML document. Or just use FTP...

Ulrich

Isn't it correct that FTP transfers are a bit slower then HTTP transfers, but way more safe? Or did I misunderstood somebody somewhere?:p

Ulrich
02-19-2009, 05:15 PM
FTP was created to transfer data, as text or binary. There is no overhead, and no reason why it should be slower than HTTP, unless your ISP is throttling traffic.

Ulrich

Imagine Programming
02-19-2009, 06:41 PM
FTP was created to transfer data, as text or binary. There is no overhead, and no reason why it should be slower than HTTP, unless your ISP is throttling traffic.

Ulrich

Well indeed, as i sayd, I heard it somewhere but never experienced it myself.