Foros del Web » Programando para Internet » PHP »

subir fichero por ftp y datos a bd

Estas en el tema de subir fichero por ftp y datos a bd en el foro de PHP en Foros del Web. no se si será la mejor manera de hacerlo pero lo que estoy buscando es el código para que pueda subir archivos desde mi web ...
  #1 (permalink)  
Antiguo 15/10/2003, 07:32
 
Fecha de Ingreso: junio-2001
Ubicación: Sevilla
Mensajes: 121
Antigüedad: 22 años, 10 meses
Puntos: 0
subir fichero por ftp y datos a bd

no se si será la mejor manera de hacerlo pero lo que estoy buscando es el código para que pueda subir archivos desde mi web mediante un formulario a una cuenta ftp (está parte si se como va) y tomar algunos datos de este archivo,como nombre y tamaño, para mostrarlos en otra página, y que cuando pulsen por ej. sobre el nombre, lo puedan descargar los usuarios que visitán mi web.

sabe alguine donde puedo ver un ejemplo de esto?

gracias.
__________________
salu2
filly
  #2 (permalink)  
Antiguo 15/10/2003, 08:28
 
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
  #3 (permalink)  
Antiguo 16/10/2003, 01:51
 
Fecha de Ingreso: junio-2001
Ubicación: Sevilla
Mensajes: 121
Antigüedad: 22 años, 10 meses
Puntos: 0
web y ftp mismos server

estimado amigo,

en efecto mi web y el ftp donde deseo subir los archivos los tengo en el mismo server.

voy a probar este código. gracias.
__________________
salu2
filly
  #4 (permalink)  
Antiguo 16/10/2003, 01:57
 
Fecha de Ingreso: junio-2001
Ubicación: Sevilla
Mensajes: 121
Antigüedad: 22 años, 10 meses
Puntos: 0
otra opción

lo de alojarlo en la base de datos es por que creia que era la única manera de hacer esto.

¿yo puedo subir un fichero desde un formulario y luego mostrarlo en una web para que se pueda descargar?'

¿como se haría para coger la ruta?

ambién quisiera en el formulario de subida poder poner una breve explicación del fichero. Es por lo que no veo otra opción que la de bd.
__________________
salu2
filly
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:11.