Foros del Web » Programando para Internet » PHP »

Subir archivos para luego descargarlos con dreamviewer

Estas en el tema de Subir archivos para luego descargarlos con dreamviewer en el foro de PHP en Foros del Web. saludos, dentro del proyecto escolar que estoy realizando estoy creando una pequeña plataforma elearning, en la cual el tutor crea un curso y adjunta cualquier ...
  #1 (permalink)  
Antiguo 28/05/2015, 08:42
 
Fecha de Ingreso: mayo-2015
Mensajes: 53
Antigüedad: 9 años
Puntos: 0
Subir archivos para luego descargarlos con dreamviewer

saludos, dentro del proyecto escolar que estoy realizando estoy creando una pequeña plataforma elearning, en la cual el tutor crea un curso y adjunta cualquier tipo de material al mismo, ya hice el formulario donde ingrese los datos generales al curso pero no puedo lograr hacer que suba archivos varios, solo puedo subir fotos, pero necesito que se pueda subir lo que sea y asi mismo luego pueda ser descargado, porfavor ayudenme con ese problema

adjunto el codigo que tengo hasta el momento:
Código PHP:
<?php require_once('Connections/local.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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")) {
  
$insertSQL sprintf("INSERT INTO tematicas (tematicaNombre, docenteId, tematicasMaterial) VALUES (%s, %s, %s)",
                       
GetSQLValueString($_POST['tematicaNombre'], "text"),
                       
GetSQLValueString($_POST['docenteId'], "int"),
                       
GetSQLValueString($_POST['tematicasMaterial'], "text"));

  
mysql_select_db($database_local$local);
  
$Result1 mysql_query($insertSQL$local) or die(mysql_error());

  
$insertGoTo "cursos.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_local$local);
$query_consultadocentes "SELECT * FROM docentes";
$consultadocentes mysql_query($query_consultadocentes$local) or die(mysql_error());
$row_consultadocentes mysql_fetch_assoc($consultadocentes);
$totalRows_consultadocentes mysql_num_rows($consultadocentes);
?>
<!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"><!-- InstanceBegin template="/Templates/plantillabase.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Documento sin título</title>


<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="css/estiloprincipal.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/menu.css" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Belleza&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link href="css/cuadroregistro.css" rel="stylesheet" type="text/css" />
<link href="css/cuadrologin.css" rel="stylesheet" type="text/css" />
<link href="css/cuadrosubircurso.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="container">
  <div class="header">
  <?php include("includes/cabecera.php"); ?>
  <div class="clearfloat"></div>
  <?php include("includes/menu.php"); ?>

    <?php include("includes/sesion.php"); ?>
  
</div>
  <div class="sidebar1"><!-- InstanceBeginEditable name="ContenidoIzq" -->  <!-- InstanceEndEditable --><!-- end .sidebar1 --></div>
<div class="content"><!-- InstanceBeginEditable name="ContenidoDer" --> Completa la siguiente informacion para proceder a crear tu curso:
  
  <div id ="cuadrosubircurso">
    <form action="<?php echo $editFormAction?>" method="post" name="form1" id="form1">
      <table align="center">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">TematicaNombre:</td>
          <td><input type="text" name="tematicaNombre" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">DocenteId:</td>
          <td><select name="docenteId">
            <?php 
do {  
?>
            <option value="<?php echo $row_consultadocentes['docenteId']?>" ><?php echo $row_consultadocentes['docenteId']?></option>
            <?php
} while ($row_consultadocentes mysql_fetch_assoc($consultadocentes));
?>
          </select></td>
        </tr>
        <tr> </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">TematicasMaterial:</td>
          <td><input type="text" name="tematicasMaterial" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td><input type="submit" value="Insertar registro" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    <p>&nbsp;</p>
  </div>
<!-- end .content -->
  <!-- InstanceEndEditable --></div>
  <div class="footer">
 <?php include("includes/pie.php"); ?>
 </div>
  <!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result
($consultadocentes);
?>
  #2 (permalink)  
Antiguo 28/05/2015, 11:26
 
Fecha de Ingreso: mayo-2015
Mensajes: 53
Antigüedad: 9 años
Puntos: 0
Respuesta: Subir archivos para luego descargarlos con dreamviewer

por favor ayuda, reviasndo el foro me encontré con esto http://www.forosdelweb.com/f18/subir-bajar-archivos-desde-base-datos-con-php-789944/ pero no logro hacer que se suba el registro..

Asi lo tengo en mi codigo:

Código PHP:
Ver original
  1. <?php  
  2. $conn = mysql_connect ("localhost","root","");  
  3. mysql_select_db("ambientevirtual");
  4.  
  5.  
  6. $archivo = $_FILES["material"]["tmp_name"];  
  7. $tamanio = $_FILES["material"]["size"];
  8. $tipo    = $_FILES["material"]["type"];
  9. $nombre  = $_FILES["material"]["name"];
  10.  
  11.  
  12.  if ( $archivo != "none" )
  13.  {
  14.     $fp = fopen($archivo, "rb");
  15.     $contenido = fread($fp, $tamanio);
  16.     $contenido = addslashes($contenido);
  17.     fclose($fp);  
  18.  
  19.     $qry = "INSERT INTO tematicas (tematicasMaterial) VALUES  
  20.           (0,'$nombre','$contenido','$tipo')";
  21.            
  22.  
  23.     mysql_query($qry);
  24.  
  25.     if(mysql_affected_rows($conn) > 0)
  26.        print "Se ha guardado el archivo en la base de datos.";
  27.     else
  28.        print "NO se ha podido guardar el archivo en la base de datos.";
  29.  }
  30.  else
  31.     print "No se ha podido subir el archivo al servidor";
  32. ?>

"ambientevirtual" es el nombre de la base de datos
"tematicas" es el nombre de la tabla,
"tematicasMaterial" es el nombre del campo dentro de la tabla donde debería guardarse el archivo.


no se porque al ingresar el registro me sale "NO se ha podido guardar el archivo en la base de datos."

Etiquetas: formulario, html, mysql, registro, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:16.