Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/03/2010, 16:43
larraga
 
Fecha de Ingreso: diciembre-2009
Mensajes: 36
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: Problema formato del fichero download

Hola,

El script de subida es el siguiente:
$rpta1 = "";
if ($_POST["action"] == "upload") {
$tmpfile = $_FILES['archivo']['tmp_name'];
$tmpname = $_FILES['archivo']['name'];
$filesize = $_FILES['archivo']['size'];
$ruta = 'wwww.dominio.es/ruta del fichero';
$tipo = $_FILES['archivo']['type'];
// se definen los valores de la conexion ftp y el directorio al que ira el fichero
$ftpuser = "usuario_ftp";
$ftppass = "passw_ftp";
$ftppath = "ftp.dominio/ruta del fichero";
$ftpurl = "ftp://".$ftpuser.":".$ftppass."@".$ftppath;
if ($tmpname != "") {
$fp = fopen($tmpfile, 'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ftpurl.$tmpname);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($tmpfile));
curl_exec($ch);
$error = curl_errno($ch);
curl_close ($ch);
if ($error == 0) {
$rpta1 = 'Archivo subido correctamente.';
} else {
$rpta1 = 'Error al subir el archivo.';
}
} else {
$rpta1 = 'Seleccionar un archivo.';
}
}

El script de bajada es el siguiente:


$id=$_GET["id"]; //nombre del fichero
$ruta = "www.dominio/ruta del fichero";
$enlace = $ruta."/".$id;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Type:application/force-download");
header("Content-Type: application/octet-stream");
header ("Content-Disposition: attachment; filename=".$enlace);
header("Content-Transfer-Encoding: binary ");
readfile($enlace);

saludos