|  | 
	                
  
    | 
	 
        ช่วยหน่อยครับ!ทำไมอัพลงฐานข้อมูลไม่ได้ มันติดอะไรหรือป่าวครับ     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | Code (PHP) 
 <?php 
		include ("../include/connect.php");
		
		date_default_timezone_set('Asia/Bangkok');
		
		$id_album = $_GET['id_album'];
		
		for($i=0;$i<count($_FILES["picture"]["name"]);$i++)
	{
		if(trim($_FILES["picture"]["tmp_name"][$i]) != "")
		{
			$images = $_FILES["picture"]["tmp_name"][$i];
			$images_file = $_FILES["picture"]["type"][$i];
			$images_time = date('YmdHis');
			srand((double)microtime()*1000000); //ทำการสุ่มชื่อ
			$Pic_name=$random_pic = rand(1,9999999);
			if( $images_file == "image/gif" )
			{
			$filename = $Pic_name.".gif";
			}
			if (($images_file=="image/jpg")||($images_file=="image/jpeg")||($images_file=="image/pjpeg"))
			{
			$filename = $Pic_name.".jpg";
			}
			$new_images = "img-"."$images_time"."$filename";
			
			$width=500; 
			$size=GetimageSize($images);
			$height=round($width*$size[1]/$size[0]);
			if( $images_file == "image/gif" )
			{
			$images_orig = ImageCreateFromGIF($images);
			}
			if (($images_file=="image/jpg")||($images_file=="image/jpeg")||($images_file=="image/pjpeg"))
			{
			$images_orig = ImageCreateFromJPEG($images);
			}
			$photoX = ImagesX($images_orig);
			$photoY = ImagesY($images_orig);
			$images_fin = ImageCreateTrueColor($width, $height);
			ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
			ImageGIF($images_fin,"../images/images_activity/".$new_images);
			ImageJPEG($images_fin,"../images/images_activity/".$new_images);
			ImageDestroy($images_orig);
			ImageDestroy($images_fin);
}
} 
			
			$sl="INSERT INTO  picture(picture,id_album)  VALUES ('','$new_images','$id_album')";
			$result= mysqli_query($conn,$sl);
			if ($result)
		{header("location:load_article.php");
}else{echo "<center>ไม่สามารถบันทึกข้อมูลได้</center>";
}
		?>
 
 
 Tag : PHP, HTML5, Appserv, Windows
 
 
 |  
            | 
 ประวัติการแก้ไข
 2019-08-20 03:21:46
 2019-08-20 03:23:06
 |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2019-08-20 03:20:56 | By :
                          2361670670565792 | View :
                          686 | Reply :
                          5 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ค่าที่ส่งไปครับ(PHP) 
 <?php $id_album = $_GET['id_album'];
				  $xl="SELECT * FROM `category_album` WHERE `id_album` =$id_album";
				  $r=mysqli_query($conn,$xl);
				  while($data = mysqli_fetch_array($r)) {
					  $id_album = $data ['id_album'];
					  $id_activity = $data ['id_activity'];
					  $album = $data ['album'];
					  $description = $data ['description'];
					  $username = $data ['username'];
				  }
				  ?>
				<div class="container">
				<div class="row">
				<div class="col-md-2">
				</div>
				<div class="col-md-8">
				<div class="row">
				<div class="col-md-12 mx-auto">
									
				<div class="form-group" >
				<div class="card border-primary" >
				<h5 class="card-header border-primary text-primary bg-primary" ><font color="white"><center>เพิ่มรูปภาพ</h5></center></font>
								  <div class="card-body">
				 <form action="upload_photo2.php" method="post" enctype="multipart/form-data">
				<center>
					<label>  <h6>  AlbumID : <?= $id_album; ?> </h6></label>              
					<label>    <?= $album; ?> </label></center><p>
					<label>  อัพโหลดรูปภาพ  :</label>
					<input type="file" name="picture[]" id="picture" multiple="multiple" class="form-control ">
														
<center>
					<a href="javascript:history.back()" class="btn btn-success "><i class="fa fa-reply"></i> ย้อนกลับ</a>
					<button type="reset" class="btn btn-warning"><i class="fa fa-refresh"></i> รีเซ็ต</Button>
					<button type="submit" class="btn btn-danger"><i class="fa fa-save fa-lg"></i> บันทึกข้อมูล</button></center>
								  
								</form>
								</div>  
								</div>
								</div>
								</div>
								</div>
								</div>
								<div class="col-md-2">
								</div>
								</div>
								</div>
								  </body>
								</html>	
 |  
              | 
 ประวัติการแก้ไข
 2019-08-20 03:25:59
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2019-08-20 03:24:31 | By :
                            2361670670565792 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 $sl="INSERT INTO  picture(picture,id_album)  VALUES ('','$new_images','$id_album')";
 มันตรงคอลัมน์กันมั้ย?
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2019-08-20 04:53:08 | By :
                            mr.v |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ต้องนี้อัพลงฐานข้อมูลแล้วนะครับ 
 แต่ผมอัพไฟล์รูปไป 2 ไฟล์ แต่มันบันทึกลงฐานข้อมูลแค่ไฟล์เดี้ยวครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2019-08-21 13:30:54 | By :
                            2361670670565792 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอบคุณ พี่ Mr.v มากนะครับ ผมทำได้แล้วครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2019-08-21 14:08:57 | By :
                            2361670670565792 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | . 
 |  
              | 
 ประวัติการแก้ไข
 2019-09-29 23:23:38
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2019-09-29 23:23:07 | By :
                            2361670670565792 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |