Formulario
Código PHP:
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META lang=es content="" name=Keywords>
<META content="" name=Description>
<META content=worldwide name=coverage>
<META content=all name=robots>
<META content=general name=rating>
<META content="" name=revisit-after>
<meta name="distribution" content="local">
</script>
<script language="JavaScript1.2">
<!--
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->
</script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link href="estilo.css" rel="stylesheet" type="text/css">
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="../estilo.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo1 {font-size: 16pt}
.Estilo2 {font-weight: bold}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="837" height="462" border="0" align="center" cellpadding="0" cellspacing="0" id="principal">
<tr>
<td width="2" height="462" class="leftshadow"></td>
<td width="831" height="462" valign="top" class="leftbox"><p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<form enctype="multipart/form-data" action="proacad.php" method="POST">
<label>
<div align="center">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<br />
<strong>Insertar archivo</strong>:
<input name="archivo" type="file" id="archivo" />
<input type="submit" name="enviar" value="Enviar" />
</div>
</label>
</form>
<p> </p>
</td>
<td width="4" align="center" valign="top" class="watermark"> </td>
</tr>
</table>
</body>
</html>
Código PHP:
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META lang=es content="" name=Keywords>
<META content="" name=Description>
<META content=worldwide name=coverage>
<META content=all name=robots>
<META content=general name=rating>
<META content="1 days" name=revisit-after>
<meta name="distribution" content="local">
</script>
<script language="JavaScript1.2">
<!--
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->
</script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link href="estilo.css" rel="stylesheet" type="text/css">
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="../estilo.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo1 {font-size: 16pt}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="837" height="462" border="0" align="center" cellpadding="0" cellspacing="0" id="principal">
<tr>
<td width="2" height="462" class="leftshadow"></td>
<td width="831" height="462" valign="top" class="leftbox"><p align="center"> </p>
<p align="center"><span class="titulos Estilo2 Estilo1">INSERCION DE ARCHIVOS</span></p>
<p align="center"> </p>
<div align="center">
<p><strong>Archivo recibido</strong></p>
</div>
<?php
define('HOST', 'localhost');
define('DB', 'base');
define('USERNAME', 'usuario');
define('PASSWORD', '123');
$link = @mysql_connect(HOST,USERNAME,PASSWORD);
if (!$link) {
die('En este momento no hay conexion con la base de datos.');
}
mysql_select_db(DB) or die("No se ha seleccionado base de datos.");
if (isset($_POST['enviar'])) {
$upload_dir = '../desaca/';
$upload_file = $upload_dir . $_FILES['archivo']['name'];
$archivo = $_FILES['archivo']['name'];
if (move_uploaded_file($_FILES['archivo']['tmp_name'], $upload_file)) {
$query = "INSERT desaca SET archivo='$archivo'";
mysql_query($query);
} else {
}
}
?>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p></td>
<td width="4" align="center" valign="top" class="watermark"> </td>
</tr>
</table>
</body>
</html>