RE: [PHP-ES] Download de archivo
| From: | marolijo at yahoo dot es | Date: | Wed, 30 Jun 2004 11:00:01 +0000 |
| Subject: | RE: [PHP-ES] Download de archivo | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-49714@lists.php.net to get a copy of this message | ||
<?php
$file = "docs/";
$file .= $_GET['fitxer'];
$speed = 22.0; // 8,5 kb/s download rate limit
if(file_exists($file) && is_file($file)) {
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Content-Disposition: filename=$file");
flush();
$fd = fopen($file, "r");
while(!feof($fd)) {
echo fread($fd, round($speed*1024));
flush();
sleep(1);
}
fclose ($fd);
}else{
echo "Fitxer no trobat: <br><br>Envia un avís a l'administrador <a
href=?id=108&subject=Error Descarregar
fitxer&to=webmaster>webmaster@...</a>";
}
?>
Ok, gracias a todos, con este código ya me funciona. Ahora quiero actualizar
el contador en la BD, ya se que es simple pero no consigo hacerlo funcionar.
Alguien ve algun error en el siguiente código?
muchas gracias
<?php
$ud_id=$_GET['id'];
$ud_first=$_GET['contador'];
$username="...";
$password="...";
$database="...";
$db = "...";
mysql_connect($db,$username,$password);
$query="UPDATE documents WHERE id='$ud_id' SET contador='$ud_first'";
mysql_query($query);
echo "Record Updated";
mysql_close();
?>