Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/06/2003, 10:38
Avatar de asinox
asinox
 
Fecha de Ingreso: enero-2002
Ubicación: Santo Domingo
Mensajes: 2.712
Antigüedad: 22 años, 2 meses
Puntos: 6
php upload + un codigo para insertar a BD

Hola, tengo la extension php Upload y me funciona a la perfeccion, ahora bien, esta solo tiene un input tipo file para subir archivos... pero no tiene mas nada... y, yo necesito aparte de subir el archivo a una carpeta que tambien me inserte unos campos mas a una base de datos... como el nombre del archivo, ,etc..
como le agrego el insert para entrar esos datos a la bd ?Saludos


Codigo phpUplod:
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "upload");
define("no_error", "ok.html");
define("yes_error", "error.html");
$_accepted_extensions_ = "";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
$_file_ = $HTTP_POST_FILES['file'];
if(is_uploaded_file($_file_['tmp_name']) && $HTTP_POST_FILES['file']['error'] == 0){
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" enctype="multipart/form-data" method="post" action="">
<input type="file" name="file">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


Saludos
__________________
www.dataautos.com