Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/02/2004, 08:21
Tato
 
Fecha de Ingreso: agosto-2002
Ubicación: Capital Federal
Mensajes: 98
Antigüedad: 21 años, 8 meses
Puntos: 1
// -------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "../../../htm");
define("no_error", "ok.htm");
define("yes_error", "noupload.htm");
$_accepted_extensions_ = "";
// CHEQUEO DATOS
if ($carpeta = 0) {
header("Location: " . yes_error);
}
// -------------
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
/* modify */
if(!empty($HTTP_POST_FILES['file'])){
if(is_uploaded_file($HTTP_POST_FILES['file']['tmp_name']) && $HTTP_POST_FILES['file']['error'] == 0){
$_file_ = $HTTP_POST_FILES['file'];
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "Archivo demasiado pesado";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Extensión inválida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Carpeta destino inválida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER ."/". $_name_)){
// Acá grabo en la db la información del formulario
// Recupero Variables
$var_cronogramaID=$HTTP_GET_VARS['cronogramaID'];
$var_comisionID=$HTTP_POST_VARS['comisionID'];
$var_file=$HTTP_POST_VARS['file'];
$var_copete=$HTTP_POST_VARS['copete'];
$var_activa=$HTTP_POST_VARS['activa'];
$var_carpeta=$HTTP_POST_VARS['carpeta'];
// Inserto en la base de datos
$consulta_insertar = "INSERT INTO ordendia (ordendiaID, cronogramaID, comisionID, copete, archivo, activa, carpeta) VALUES ('', '$var_cronogramaID', '$var_comisionID', '$var_copete', '$_name_', '$var_activa', '$var_carpeta')";
mysql_query($consulta_insertar,$conexion) or die("No se pudo insertar los datos en la base de datos.");
// Fin de Grabación
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
}
?>