Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/08/2015, 19:52
Silenn
 
Fecha de Ingreso: julio-2015
Ubicación: Distrito Federal
Mensajes: 97
Antigüedad: 8 años, 9 meses
Puntos: 2
Respuesta: Problema con inserción de archivo en php y mysql

Gracias por responder, el código para subir los archivos es éste:

Código PHP:
<?php
$uploadedfileload
="true";
$uploadedfile_size=$_FILES['uploadedfile'][size];
echo 
$_FILES[banner][name];
if (
$_FILES[banner][size]>200000)
{
$msg=$msg."El archivo es mayor que 200KB, debes reduzcirlo antes de subirlo<BR>";
$uploadedfileload="false";}

if (!(
$_FILES[banner][type] =="image/pjpeg" OR $_FILES[banner][type] =="image/gif" OR $_FILES[banner][type] =="image/png"))
{
$msg=$msg." Tu archivo tiene que ser JPG o GIF. Otros archivos no son permitidos<BR>";
$uploadedfileload="false";}

$file_name=$_FILES[banner][name];
$add="banners/$file_name";
if(
$uploadedfileload=="true"){

if(
move_uploaded_file ($_FILES[banner][tmp_name], $add)){
echo 
" Ha sido subido satisfactoriamente";
}else{echo 
"Error al subir el archivo";}

}else{echo 
$msg;}
?>
Y el codigo para insertar el sql es éste:
Código PHP:
$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

$banner $_POST['banner'];

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO affiliates (id,name,banner,type,url,owner) VALUES (%s, %s, '$banner', %s, %s, %s)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['name'], "text"),
                       
GetSQLValueString($_POST['type'], "text"),
                       
GetSQLValueString($_POST['url'], "text"),
                       
GetSQLValueString($_POST['owner'], "text"));

  
mysql_select_db($database$connection);
  
$Result1 mysql_query($insertSQL$connection) or die(mysql_error());

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