|
|
|
upload file ไม่เข้าครับผมผิดตรงไหนครับ รบกวนแนะนำหน่อยครับ _/|\_ |
|
|
|
|
|
|
|
Code (PHP)
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
}
}
?>
Tag : PHP, MySQL, HTML, CSS
|
|
|
|
|
|
Date :
2018-06-15 17:59:04 |
By :
witsarut_bell |
View :
582 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มี <input type="file" name="file">
$_FILES['file'] ต้องรับมาจาก <input type="file" name="file">
$_FILES['aaa'] ต้องรับมาจาก <input type="file" name="aaa">
เปรียบเทียบเอาเอง
|
|
|
|
|
Date :
2018-06-16 10:50:10 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|