Jump to content

PHP uploadošana neizdodās


Vo1The
 Share

Recommended Posts

Tātad radusies neliela problēma ar upload !

Drošvien kļūda ir ļoti muļķīga bet meiģinu jau vairākas stundas no visām pusēm un nevaru saprast kas pa vainu !

 

Notice: Undefined index: bilde in /var/www/others/httpdocs/rjv/x7/modules/gallery_pic_check_add.php on line 10


Notice: Undefined index: bilde in /var/www/others/httpdocs/rjv/x7/modules/gallery_pic_check_add.php on line 11
Notice: Undefined index: bilde in /var/www/others/httpdocs/rjv/x7/modules/gallery_pic_check_add.php on line 12
Notice: Undefined index: bilde in /var/www/others/httpdocs/rjv/x7/modules/gallery_pic_check_add.php on line 13

Seit ir šīs pieminētās līnijas

                $file_type     = $_FILES['bilde']['type'];
               $file_name      = $_FILES['bilde']['name'];
               $file_size       = $_FILES['bilde']['size'];
               $file_tmp        = $_FILES['bilde']['tmp_name'];

 

 

 

Itkā vaina ir tajā ka viņš neatrod inputu cik saprotu bet laižot inputu caur $_POST viņš izvada bildes nosaukumu !

CHMOD ir atļauts aukšuplādēt gan tam gan visām pārējām sub mapēm lai gan par to nemaz viņš nelamājās !

Sēit ir skripts kurā notiek darbība jeb otrā skriptā pieminētais gallery_pic_check_add.php

<?php


if(isset($_POST['submit'])) {
$message_display = 1;
if(isset($_POST['title']) && isset($_POST['sub']) && isset($_POST['bilde'])) {
	$formaats	 = array(".gif",".jpg",".png",".jpeg",".bmp"); // Atlautie formāti		
  	 $file_type	= $_FILES['bilde']['type'];
	$file_name	= $_FILES['bilde']['name'];
	$file_size	 = $_FILES['bilde']['size'];
	$file_tmp	 = $_FILES['bilde']['tmp_name'];
	$ext = strrchr($file_name,'.');
	$ext = strtolower($ext);
	$jaunais_vaards = "Rīgas_Juglas_Vidusskola";
	if((strlen($_POST['title']) < 1) && isset($_POST['sub'])&& isset($_POST['bilde']) ) {
		$message_type = 'error';
		$message = 'Aizpildi visus laukus.';
		// Parbauda vai bilde ir pievienota
	}elseif(!is_uploaded_file($file_tmp)){
		$message_type = 'error';
		$message = 'Tu aizmirsi pievienot bildi';
		// Parbauda vai formats ir īstais
	}else if (!in_array($ext,$formaats)) {
		$message_type = 'error';
		$message = 'Nepareiz bildes formāts.';
	} else {

	// Parbaudam formatu
	if($file_size){
		if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
			$new_img = imagecreatefromjpeg($file_tmp);
		}elseif($file_type == "image/x-png" || $file_type == "image/png"){
			$new_img = imagecreatefrompng($file_tmp);
		}elseif($file_type == "image/gif"){
			$new_img = imagecreatefromgif($file_tmp);
		}

	   list($width, $height) = getimagesize($file_tmp);

   	 // Parveidojam bildes izmeru ja tas parsniedz lieliumu
	   if (($width > 800) && ($height > 600)) {
		$resized_img = imagecreatetruecolor(800,600);  
		imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, 800, 600, $width, $height);		  
		ImageJpeg($resized_img, $base_admin_url."/uploads/bildes/$jaunais_vaards_$file_ext", 95);
		// Ja bilde vis kartiba uplodojam to
		} else {
		move_uploaded_file($file_tmp, $_SERVER['DOCUMENT_ROOT']."/x7/uploads/bildes/$jaunais_vaards_$file_ext");
		}

	   // Veidojam mazo bildi
	   $resized_img = imagecreatetruecolor(204,109);  
	   imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, 204, 109, $width, $height);		  
	   ImageJpeg($resized_img, $_SERVER['DOCUMENT_ROOT']."/x7/uploads/bildes/small/$jaunais_vaards_$file_ext", 95);
	   ImageDestroy ($resized_img);
	   ImageDestroy ($new_img);

	   }
		//ievietojamie dati
		$title = mysql_real_escape_string($_POST['title']);
		$sub = (int)$_POST['sub'];
		$time = UNIX_TIMESTAMP();
		$file = $jaunais_vaards."_".$file_ext;

		$message_type = 'success';
		$message = 'Aktualitāte veiksmīgi pievienota.';
		$closed_box = 'closed-box';

		//ievietoajam datus
			$post = array(
				'timestamp'=>$time,
				'title'=>$title,
				'in'=>$sub,
				'pic'=>$file,
			);
			insert_array('x7_gallery_pic', $post);
	}
}	 else {
	$message_type = 'error';
	$message = 'Aizpildi visus laukus.';
	}
}else {
	$message_display = 0;
}
?>

 

Te ir skripts kurā atrodās Inputi

 


  <noscript> <!-- Show a notification if the user has disabled javascript -->
<div class="notification error png_bg">
 <div>
  Javascript is disabled or is not supported by your browser. Please <a href="http://browsehappy.com/" title="Upgrade to a better browser">upgrade</a> your browser or <a href="http://www.google.com/support/bin/answer.py?answer=23852" title="Enable Javascript in your browser">enable</a> Javascript to navigate the interface properly.
 Download From <a href="http://www.exet.tk">exet.tk</a></div>
</div>
  </noscript>

  <!-- Page Head -->
  <h2>Aktualitātes</h2>
  <p id="page-intro">Pievienot aktualitāti</p>

  <?php
require_once('gallery_pic_check_add.php');
if($message_display == 1) {
 echo '<div class="notification '.$message_type.' png_bg">
   <a href="#" class="close"><img src="'.$base_admin_url.'resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
	<div>
	 '.$message.'
	</div>
   </div>';
}
  ?>

  <div class="content-box <?=$closed_box;?>"><!-- Start Content Box -->

<div class="content-box-header">

 <h3>Aktualitātes</h3>

 <ul class="content-box-tabs">
  <li><a href="#tab1" class="default-tab">Pievienot</a></li>
 </ul>

 <div class="clear"></div>

</div> <!-- End .content-box-header -->

<div class="content-box-content">

 <div class="tab-content default-tab" id="tab1">

  <form action="" method="post">

   <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->


	<p>
	 <label>Nosaukums</label>
	  <input class="text-input small-input" type="text" id="small-input" maxlength="40" name="title" />
	  <br /><small>Nosaukums atpazīšanai kas būs redzams tikai admin panelī</small>
	</p>



	<p>
	<label>Bildes</label>

	   <div id="bildes">
	   <input type="file" name="bilde" />
	   </div>
	  <a href="javascript:;" onclick="add_bilde();">Pievienot vēlvienu bildi</a>
	  <br /><small>Atlautie formāti : .gif .jpg .png .jpeg .bmp</small>
	</p>

	<p>
	 <label>Apakš galerija</label>			
	 <select name="sub" class="small-input">
	 <option value="0">Galerija</option>
	 <?php
	  $query = mysql_query("SELECT * FROM x7_gallery");
	   while($row = mysql_fetch_array($query)){
	echo '<option value="'.$row['id'].'">'.$row['title_lv'].'</option>';
   }
?>
	 </select>
	 <br /><small>Visas bildes tiks ievietotas šajā sadaļā</small>
	</p>



	<p>
	 <input name="submit" class="button" type="submit" value="Pievienot" />
	</p>

   </fieldset>

   <div class="clear"></div><!-- End .clear -->

  </form>

 </div> <!-- End #tab2 -->	  

</div> <!-- End .content-box-content -->

  </div> <!-- End .content-box -->

  <div id="footer">
<small> <!-- Remove this notice or replace it with whatever you want -->
  © Copyright <?=date('Y');?> x7 Admin Panel | <a href="#">Uz augšu</a>
</small>
  </div><!-- End #footer -->

 

Būšu pateicīgs par jebkādu palīdzību !

Labots - Vo1The
Link to comment
Share on other sites

Pirmais draudzīgais ieteikums - postojot forumā ko tādu, izvāc no HTML visu lieko un atstāj tikai *svarīgo* daļu (šajā gadījumā - forma bez visādiem <noscript>, <div id="footer">, nevajadzīgiem HTML komentāriem utt).

 

Par kļūdu - kad uploado failus, formai jānorāda enctype="multipart/form-data". Piemēri šeitan.

  • Patīk 1
Link to comment
Share on other sites

Ok nākoš reiz kad būs vajadzība tiks darīts !

Ieliku formā enctype bet tikuntā rādās noice !

EDIT : atvainojos sanāca ar to enctype !

Paldies nezināju par to !

Labots - Vo1The
Link to comment
Share on other sites

Izveido kontu, vai pieraksties esošajā, lai komentētu

Jums ir jābūt šī foruma biedram, lai varētu komentēt tēmas

Izveidot jaunu kontu

Piereģistrējies un izveido jaunu kontu, tas būs viegli!

Reģistrēt jaunu kontu

Pierakstīties

Jums jau ir konts? Pierakstieties tajā šeit!

Pierakstīties tagad!
 Share

×
×
  • Izveidot jaunu...