|
 |
|
ต้องการส่งข้อมูลรูปภาพ เพื่อไปเก็บใน path ที่กำหนดไว้ คือ Folder Myfiles แต่รูปไม่เก็บลง path |
|
 |
|
|
 |
 |
|
ต้องการส่งข้อมูลรูปภาพ เพื่อไปเก็บใน path ที่กำหนดไว้ คือ Folder Myfiles แต่รูปไม่เก็บลง path มันลงแต่ในฐานข้อมูล ต้องใช้โค๊ดไหนถึงจะเก็บ รูปภาพลง path ที่กำหนด
index.php
<script type="text/javascript">
function save(){
var data;
var subtract_list="";
var subtract_flag;
var reject_comment="";
var sub_percentSUM = 0;
data="weightNo=" + document.getElementById("txtWeightReceiptNo").value;
data+="&pwd=" + document.getElementById("txtpwd").value;
data+="&subtract_list=" + subtract_list;
data+="&sub_percentSUM=" + sub_percentSUM;
data+="&subtract_flag=" + subtract_flag;
data+="&reject_comment=" + reject_comment;
data+="&subtract_money=" + subtract_money;
data+="&files=" + document.getElementById("files").files[0].name;
ajaxLoad('post','sql_insert.php',data,'');
return false;
}
</script>
<input type="file" name="files" id="files"/>
sql_insert.php
<?php header("Content-Type:text/javascript; charset=utf-8");
require_once("condb.php");
$weightNo = iconv('utf-8','windows-874',$_POST['weightNo']);
$subtract_list = iconv('utf-8','windows-874',$_POST['subtract_list']);
$subtract_flag = iconv('utf-8','windows-874',$_POST['subtract_flag']);
$reject_comment = iconv('utf-8','windows-874',$_POST['reject_comment']);
$subtract_money = iconv('utf-8','windows-874',$_POST['subtract_money']);
$sub_percentSUM = iconv('utf-8','windows-874',$_POST['sub_percentSUM']);
$files = iconv('utf-8','windows-874',$_POST['files']);
if ($_FILES["files"]["error"] > 0) {
echo "Error: " . $_FILES["files"]["error"] . "<br />";
} else {
move_uploaded_file($_FILES["files"]["tmp_name"],"myfile/" . $_FILES["files"]["name"]);
// Get fileURL path and show success alert
global $fileURL;
$fileURL = "myfile/" . $_FILES["files"]["name"];
$file= $_FILES["files"]["name"];
$sql="insert into i_scales_TQCS_H values('".$weightNo."','".date('Y-m-d')."','".date('H:i')."','".$member_id."','".$member_name."','".$subtract_status."','".$sub_service1_Flag."','".$sub_service2_Flag."','".$sub_percentSUM."',NULL, '".$file."') ;";
}
?>
Tag : PHP, Ms SQL Server 2014, HTML, JavaScript, Ajax, jQuery

|
ประวัติการแก้ไข 2019-07-05 09:15:08
|
 |
 |
 |
 |
Date :
2019-07-05 08:53:01 |
By :
aumebun |
View :
908 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เห็นมีคำสั่ง upload file เลยครับ 
|
 |
 |
 |
 |
Date :
2019-07-05 09:00:40 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
https://www.php.net/manual/en/function.move-uploaded-file.php
เก็บผลการทำงาน move_uploaded_file() ใส่ตัวแปร เช่น $moveUploadResult = move_uploaded_file(...);
แล้ว
Code (PHP)
var_dump($moveUploadResult);
exit();
ดูว่าได้อะไร
check permission หรือยัง?
ลอง echo realpath('myfile/');exit(); ก่อน move upload ดูว่าได้อะไร?
|
 |
 |
 |
 |
Date :
2019-07-05 19:00:39 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|