|
|
|
ช่วยดูให้หน่อยนะคะ จะอัพโหลดข้อมูล มันบอกว่าอัพได้แต่พอเข้าไปดูมันไม่มีค่ะ |
|
|
|
|
|
|
|
UploadProject.php
Code (PHP)
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script href="bootstrap1/js/bootstrap.min.js" rel="stylesheet"></script>
<link href="bootstrap1/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap1/css/bootstrap-responsive.min.css" rel="stylesheet">
</head>
<!--<script>
$(document).ready(function() {
$("form").validate({
rules: {test: {minlength: 3,email: true}},
showErrors: function(errorMap, errorList) {
$.each(this.successList, function(index, value) {return $(value).popover("hide");});
return $.each(errorList, function(index, value) {
var _popover;
console.log(value.message);//message from popover
_popover = $(value.element).popover({
trigger: "manual",
placement: "top",
content: value.message,
template: "<div class=\"popover\"><div class=\"arrow\"></div><div class=\"popover-inner\"><div class=\"popover-content\"><p></p></div></div></div>"
});
_popover.data("popover").options.content = value.message;
return $(value.element).popover("show");
});
}
});
});
</script>-->
<body>
<form method="post" action="saveUpload.php" enctype="multipart/form-data">
<fieldset>
<legend>Upload Project</legend>
Project Name : <input name="Name" id="Name" type="text" placeholder="Type something"/>
Advisor : <input name="Lang" id="Lang" type="text" placeholder="Type something"/>
</fieldset>
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="input-append">
<div class="uneditable-input span3"><i class="icon-file fileupload-exists"></i><span class="fileupload-preview"></span></div>
<span class="btn btn-file">
<span class="fileupload-new">Select file</span>
<span class="fileupload-exists">Change</span>
<input type="file" name="File"></span><a class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
<input type="submit" name="Submit" value="Save" class="btn">
<br/> <br/><br/>
</form>
<script src="http://code.jquery.com/jquery-1.7.min.js" ></script>
<script src="bootstrap/FileUpload/bootstrap-fileupload.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
unlock();
$("[name=Language]").change(function(){
unlock();
});
});
function unlock(){
if($("[name=Language]").is(':checked')){
$("[name=Lang]").attr("disabled",false);
}
else{
$("[name=Lang]").attr("disabled",true);
}
}
</script>
</body>
</html>
saveUpload.php
Code (PHP)
<?
mysql_connect("localhost","root","123");
mysql_select_db("test");
if($_FILES["File"]["name"] != "")
{
//*** Read file BINARY ***'
$fp = fopen($_FILES["File"]["tmp_name"],"r");
$ReadBinary = fread($fp,filesize($_FILES["File"]["tmp_name"]));
fclose($fp);
$FileData = addslashes($ReadBinary);
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","123") or die("Error Connect to Database");
$objDB = mysql_select_db("test");
$strSQL = "INSERT INTO test(Name,Proj,Language VALUES ('".$_POST["Name"]."','".$FileData."','".$_POST["Lang"]."')";
$objQuery = mysql_query($strSQL);
echo "Copy/Upload Complete<br>";
mysql_close($objConnect);
} else {
echo "cannot uploadfile";
}
?>
รบกวนดูให้หน่อยนะค่ะ ขอบคุณมากคะ
Tag : PHP
|
ประวัติการแก้ไข 2013-06-21 16:59:25
|
|
|
|
|
Date :
2013-06-21 16:55:37 |
By :
mrronalz |
View :
671 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
column Proj ใน database เป็นชนิด blob หรือเปล่าครับ ลองตรวจสอบดูนะครับถ้าจะอัพโหลดเข้าไป database ต้องใช้ type blob นะครับ
|
|
|
|
|
Date :
2013-06-21 17:10:49 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วค่ะ ขอบคุณมากนะค่ะ
|
|
|
|
|
Date :
2013-06-22 17:59:54 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|