Ocupo el código en php para adjuntar un archivo en phpmyadmin
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
// $imagen_nombramiento = $_POST[“File”];
if(is_uploaded_file($_FILES[‘file’][‘tmp_name’])) { // verifica haya sido cargado el archivo
$ruta= “Titulo/”.$_FILES[‘file’][‘name’];
move_uploaded_file($_FILES[‘file’][‘tmp_name’], $ruta);
}
$insertSQL = sprintf("INSERT INTO estatus_laboral (Num_Empleado, Nombre_plantel, Fecha_ingreso, Tipo_nombramiento, Clave_presupuestal, Fecha_nombramiento, imagen_nombramiento, tipo_plaza, H_S_M, Tipo_p_jornada, Jornada, jornada_H_S_M, otro_plantel, otro_subsistema) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['$ruta'], "text"),
// GetSQLValueString($ruta, “text”),
//AYUDAME A CORREGIR EL ERROR
1 respuesta
Este es todo mi código pero estoy batallando para adjuntar la imagen y si tienen alguna función para el formato de fecha
<?php require_once('Connections/academica.php');?>
<?php
mysql_select_db($database_academica, $academica);
$query_Recordset1 = "SELECT * FROM estatus_laboral";
$Recordset1 = mysql_query($query_Recordset1, $academica) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
// $imagen_nombramiento = $_POST[“File”];
if(is_uploaded_file($_FILES[‘file’][‘tmp_name’])) { // verifica haya sido cargado el archivo
$ruta= “Titulo/”.$_FILES[‘file’][‘name’];
move_uploaded_file($_FILES[‘file’][‘tmp_name’], $ruta);
}
$insertSQL = sprintf("INSERT INTO estatus_laboral (Num_Empleado, Nombre_plantel, Fecha_ingreso, Tipo_nombramiento, Clave_presupuestal, Fecha_nombramiento, imagen_nombramiento, tipo_plaza, H_S_M, Tipo_p_jornada, Jornada, jornada_H_S_M, otro_plantel, otro_subsistema) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Num_Empleado'], "int"),
GetSQLValueString($_POST['Nombre_plantel'], "text"),
GetSQLValueString($_POST['Fecha_ingreso'], "int"),
GetSQLValueString($_POST['select'], "text"),
GetSQLValueString($_POST['Clave_presupuestal'], "text"),
GetSQLValueString($_POST['Fecha_nombramiento'], "int"),
GetSQLValueString($_POST['$ruta'], "text"),
// GetSQLValueString($ruta, “text”),
GetSQLValueString($_POST['select3'], "text"),
GetSQLValueString($_POST['select6'], "text"),
GetSQLValueString($_POST['select4'], "text"),
GetSQLValueString($_POST['select5'], "text"),
GetSQLValueString($_POST['select2'], "text"),
GetSQLValueString($_POST['otro_plantel'], "text"),
GetSQLValueString($_POST['otro_subsistema'], "text"));
mysql_select_db($database_academica, $academica);
$Result1 = mysql_query($insertSQL, $academica) or die(mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<style type="text/css">
<!--
body {
background-image: url(IMAGENES/fondo_Estatus_laborall.jpg);
}
-->
</style></head>
<body>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="movie" value="button34.swf" />
<param name="quality" value="high" />
<embed src="button34.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
</object>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="BGCOLOR" value="" />
<param name="movie" value="button35.swf" />
<param name="quality" value="high" />
<embed src="button35.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
</object>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="BGCOLOR" value="" />
<param name="movie" value="button36.swf" />
<param name="quality" value="high" />
<embed src="button36.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
</object>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
<param name="movie" value="button37.swf" />
<param name="quality" value="high" />
<embed src="button37.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
</object>
</p>
<p></p>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Num_Empleado:</td>
<td><input type="text" name="Num_Empleado" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nombre_plantel:</td>
<td><input type="text" name="Nombre_plantel" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fecha_ingreso:</td>
<td><input type="text" name="Fecha_ingreso" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Tipo_nombramiento:</td>
<td><select name="select" size="1">
<option value="Definitivo">Definitivo</option>
<option value="Provisonal">Provisonal</option>
<option value="Tiempo Fijo">Tiempo Fijo</option>
<option value="Interinos">Interinos</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Clave_presupuestal:</td>
<td><input type="text" name="Clave_presupuestal" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fecha_nombramiento:</td>
<td><input type="text" name="Fecha_nombramiento" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Imagen_nombramiento:</td>
<td><input type="file" name="file" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Tipo_plaza:</td>
<td><select name="select3" size="1">
<option value="Plaza de Jornada">Plaza de Jornada</option>
<option value="HSM">HSM</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">H_S_M:</td>
<td><select name="select6" size="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Tipo_p_jornada:</td>
<td><select name="select4" size="1">
<option value="Profesor Asociado A">Profesor Asociado A</option>
<option value="Profesor Asociado B">Profesor Asociado B</option>
<option value="Profesor Asociado C">Profesor Asociado C</option>
<option value="Profesor Titular A">Profesor Titular A</option>
<option value="Profesor Titular B">Profesor Titular B</option>
<option value="Profesor Titular C">Profesor Titular C</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Jornada:</td>
<td><select name="select5" size="1">
<option value="20 Horas">20 Horas</option>
<option value="30 Horas">30 Horas</option>
<option value="40 Horas">40 Horas</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Jornada_H_S_M:</td>
<td><select name="select2" size="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Otro_plantel:</td>
<td><input type="text" name="otro_plantel" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Otro_subsistema:</td>
<td><input type="text" name="otro_subsistema" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"></td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
- Compartir respuesta