Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/10/2003, 08:28
pacoalonso79
 
Fecha de Ingreso: agosto-2003
Ubicación: Piura
Mensajes: 238
Antigüedad: 20 años, 8 meses
Puntos: 0
hola... mira yo ya he hecho algo igual a lo que tu dices y si he usado base de datos para guardar lo necesario para la ubicación de los archivos... pero quisiera hacerte una pregunta... tu estas subiendo los archivos a un ftp pero quisiera saber si tu pagina web, en done esta el formulario, esta en el mismo servidor ftp... te pregunto esto porque si es que la respuesta es si... no es necesario que uses las funcionalidades que php tiene para el manejo de ftp... bueno, creo que vale la acotación... aqui te paso un codigo para que descarges los archivos que necesite el usuario descargar... los creditos de este código son de www.phpbuilder.com

Código PHP:
<?php
 
/*******************************************************************
  * download.php
  *
  * This PHP script sends a file in such a way that most web clients
  * will offer to download the file to the client computer. It uses
  * the Content-Disposition headeer extension to RFC2616
  * (see [url]http://www.w3.org/Protocols/rfc2616/rfc2616.html[/url])
  * to suggest the web client should download the file. This is
  * implemented on most (but not all) web clients. I have tested it
  * on Mozilla, Netscape 4.78 and 6.21, Internet Explorer 5.5, lynx,
  * Konqueror and Opera. It works fully on all.
  *
  * Usage: download.php?filename=name_of_file.extension
  *
  * Examples: to download the SPSS file data.sav from index.html
  * where download.php, index.html and data.sav are all in the 
  * same directory, put a link in index.html of the form
  * <a href="download.php?data.sav">Download SPSS data file</a>.
  * You can use paths in the filename, as in
  * <a href="download.php?../include/data.sav">Download data</a>.
  *
  * You can specialise the code by putting a line of the form
  * $filename="data.sav";
  * immediately after this comment. This will allow you to send
  * exactly one file for download, viz data.sav.
  * 
  * Only one variable, $filename, is not defined by default. In
  * principle, you can send a the name of the file to download
  * through a POST request (e.g. on a form button). I haven't
  * tested this.
  *
  * Restrictions: by default you can't download files with the
  * extensions html, phtml, htm, phtm, inc, php or php3. This is to
  * avoid potential security problems. For example, it is possible
  * to use a PHP file to hide sensitive data such as the password
  * to connect to an SQL server. If we allowed this script to offer
  * php scripts for download, then a client request of the form
  * [url]http://../download.php?sensitive.php[/url] could show the raw php file.
  *
  * Security issues: see the comments under Restrictions above. If
  * in doubt, define $filename immediately after this comment and
  * use a separate script for each downloadable file. I've tried
  * using header( "Location: ... " ) to retrieve the file. It doesn't
  * work on a solaris server, but does work on gnu/linux.
  *******************************************************************/
$shortname basename($filename);
if( 
file_exists$filename )          // sanity check
    
&& !eregi"php"$filename // security check
    
&& !eregi"inc"$filename )
    && !
eregi"php3?"$filename ) ){
  
$size filesize$filename ); 
  
header("Content-Type: application/save"); 
  
header("Content-Length: $size");
  
header("Content-Disposition: attachment; filename=$shortname"); 
  
header("Content-Transfer-Encoding: binary"); 
  
$fh fopen("$filename""r"); 
  
fpassthru($fh); 
  exit; 
} else {
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD 4.01 Transitional//EN"
   "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Error en Descarga</title>
 <style type="text/css">
   <!--
   body {background-image:url(include/background.gif);
         font-family:helvetica,arial,sans-serif}
   a:hover {text-decoration:none; border-width:thin; border-style:dotted;
            background-color:#f2f2ff; color:#000000}
   a:focus {text-decoration:none; background-color:#dadae6; color:#000000}
   a:active {text-decoration:none; background-color:#ffffff; color:#000000}
   -->
 </style>
</head>
<body>
<h1>El archivo <?php print( $basename ?> no esta disponible</h1>
<p>
  Posiblemente el archivo que usted solicita no existe o usten no tiene permiso
  para descargarlo usando esta aplicación.
</p>
</body>
</html>
<?php
}
?>
Un saludo y éxitos en tu proyecto
Paco
__________________
Un hombre inteligente, caminando, llega mucho mas rápido que un torpe en coche