upload file ไม่เข้าค่ะผิดตรงไหนค่ะ รบกวนแนะนำหน่อยค่ะ _/|\_

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: upload file ไม่เข้าค่ะผิดตรงไหนค่ะ รบกวนแนะนำหน่อยค่ะ _/|\_

Re: upload file ไม่เข้าค่ะผิดตรงไหนค่ะ รบกวนแนะนำหน่อยค่ะ _/|\_

โดย mindphp » 16/06/2018 1:03 am

path กับไฟล์
$folder.$final_file
อยู่ ตำแหน่ง ถูกต้องไหม

upload file ไม่เข้าค่ะผิดตรงไหนค่ะ รบกวนแนะนำหน่อยค่ะ _/|\_

โดย supattra_su » 15/06/2018 6:08 pm

upload.php

โค้ด: เลือกทั้งหมด

        <form action="save_upload.php" method="post" enctype="multipart/form-data" class="form-horizontal" id="myform">    <div class="form-group">
                  <input class="control-label col-sm-3" type="file" name="btn-upload"  required>
                  <button class="btn btn-info" type="submit" name="btn-upload">Upload</button>
              </div>
  
              <div class="progress progress-striped active"> 
                  <div class="progress-bar" style="width: 0%"><p>0%</p></div>
              </div>
            </form>

save_upload.php

โค้ด: เลือกทั้งหมด

<?php
	 include ("module/inc/config.inc.php");
?>
	

<?php
	if(isset($_POST['btn-upload'])){

	$file=rand(1000,100000)."-".$_FILES['file']['name'];
	$file_loc = $_FILES['file']['tmp_name'];
	$file_size = $_FILES['file']['size'];
	$file_type = $_FILES['file']['type'];
	$folder ="upload_folder/";
	
	$new_size =$file_size/1024;
	$new_file_name = strtolower($file);
	$final_file = str_replace(' ','-',$new_file_name);
	
	
	if(move_uploaded_file($file_loc,$folder.$final_file)) {
		$sql="INSERT INTO tbl_uploads(file,type,size,subject,Teacher) VALUES ('$final_file','$file_type','$new_size','".$_POST['txtName']."','".$_POST['txtteacher']."')";
		$result = mysqli_query($conn,$sql);
	?>
	
<?php
	}
}
?>	
	

ข้างบน