Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/08/2013, 11:31
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
duda en subir imagen no funciona

ok es que tengo un script creado donde estoy agregandole la funcion de subir una imagen y meta en una carpeta aqui tengo el codigo

Código PHP:
Ver original
  1. // ************************************************************
  2. //      Add News Article
  3. // ************************************************************
  4.  
  5.     if ($action == "addnews") {
  6.  
  7.         // Process Add News Submition
  8.         if (isset($submit)) {
  9.  
  10.             // Form post variables
  11.             $poster     = $_POST['poster'];
  12.             $title      = $_POST['title'];
  13.             $sticky     = $_POST['sticky'];
  14.             $snippet    = $_POST['snippet'];
  15.             $article    = $_POST['article'];
  16.             $topic_id   = $_POST['topic'];
  17.             $file       = $_POST['file'];
  18.             $tamano     = $_FILES["file"]['size'];
  19.             $tipo       = $_FILES["file"]['type'];
  20.             $archivo    = $_FILES["file"]['name'];
  21.                
  22.             if (empty($poster)) {
  23.            
  24.                 $poster = $sn_user;
  25.                
  26.             }                                                                                            
  27.            
  28.             // Current Time
  29.             $timestamp  = date("F j, Y, g:i a", time());
  30.            
  31.             // Add slashes for ' and "
  32.             $snippet    = addslashes($snippet);
  33.             $article    = addslashes($article);
  34.            
  35.             // Check for required fields
  36.             if ((empty($title)) || (empty($topic_id)) || (empty($snippet))) {
  37.                
  38.                 echo "
  39.                 <p class='error'><i>Title</i>, <i>Topic</i>, and <i>Snippet</i> are required fields.</p>
  40.                 <p class='error'><a href='article.php?action=addnews'>Go Back</a></p>";
  41.                
  42.             } else {
  43.            
  44.                 $news_id = $_GET['edit'];
  45.                        
  46.                 if (isset($sticky)) {
  47.                
  48.                     // Check Access
  49.                     if (($sn_userlevel == 1) OR ($sn_userlevel == 2)) {
  50.                            
  51.                         //Remove sticky from other posts
  52.                         $query = "UPDATE simplenews_articles SET sticky = 'off' WHERE sticky = 'on'";
  53.                         $result = mysql_query($query) or die (mysql_error());          
  54.                            
  55.                     } else {
  56.                    
  57.                         echo "
  58.                         <p class='error'>You don't have access to to create sticky posts.</p>
  59.                         <p class='error'><a href='article.php?action=addnews'>Go Back</a></p>";
  60.        
  61.                     }
  62.                        
  63.                 }
  64.                
  65.                 if (!empty($news_id)) {
  66.                    
  67.                     // Check Access
  68.                     if ((($sn_user == $poster) OR ($sn_userlevel == 1) OR ($sn_userlevel == 2))) {
  69.                    
  70.                         // Update Edited Article
  71.                         $query = "UPDATE simplenews_articles SET poster = '$poster', title = '$title', sticky = '$sticky', snippet = '$snippet', article = '$article', topic = '$topic_id' WHERE news_id = '$news_id'";
  72.                         $result = mysql_query($query) or die (mysql_error());
  73.                                            
  74.                         echo "
  75.                         <p class='error'>The news article has been updated.</p>
  76.                         <p class='error'><a href='article.php'>Go Back</a></p>";
  77.            
  78.                     } else {       
  79.                    
  80.                         echo "
  81.                         <p class='error'>You don't have access to edit this post.</p>
  82.                         <p class='error'><a href='article.php'>Go Back</a></p>";
  83.                            
  84.                     }
  85.                            
  86.                 } else {
  87.                    
  88.  
  89.                    // obtenemos los datos del archivo
  90.                    $prefijo = substr(md5(uniqid(rand())),0,6);
  91.                    $destino =  "files/".$prefijo."_".$archivo;
  92.                    move_uploaded_file($_FILES['file']['tmp_name'],$destino);
  93.            
  94.                     //Insert new article
  95.                     $query = "INSERT INTO simplenews_articles (poster, title, sticky, snippet, article, date, topic, imagen) VALUES ('$poster', '$title', '$sticky', '$snippet', '$article', '$timestamp', '$topic_id', '$file')";
  96.                     $result = mysql_query($query) or die (mysql_error());
  97.                            
  98.                     echo "
  99.                     <p class='error'>The news article <i>$title</i> been added.</p>
  100.                     <p class='error'><a href='article.php'>Go Back</a></p>";
  101.                
  102.                 }
  103.            
  104.             }

todo trabaja perfecto pero no se por que no sube la imagen