|
 |
|
มีไคร มี โค้ด อัพโหลด รูป แล้ว แยก เก็บ ชื่อ ไฟล์ในดาต้าเบส เก็บรูปในโฟเดอร์ ไครมีบ้าง คับ ขอหน่อย |
|
 |
|
|
 |
 |
|
Apply จากตัวนี้ครับ
PHP สร้างฟอร์มสำหรับ Upload รูปภาพลงในฐานข้อมูล MySQL
|
 |
 |
 |
 |
Date :
2013-10-01 06:13:03 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<script language="javascript">
function show_pic(sc){
document.form1.action='upload.php';
document.form1.target='mypre';
document.form1.submit();
}
</script>
<span id="mypic1"></span>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<input type="file" name="file" onchange="show_pic(this.value);" />
<input type="submit" name="Submit" value="Submit" />
</form>
<iframe name="mypre" width="0" height="1" frameborder="0"></iframe>
upload.php
<?php
function upimg($img,$imglocate){
global $file_up;
if($img['name']!=''){
$fileupload1=$img['tmp_name'];
$g_img=explode(".",$img['name']);
$file_up=time().".".$g_img[1];
if($fileupload1){
$array_last=explode(".",$file_up);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg" or $lastname=="swf"){
@copy($fileupload1,$imglocate.$file_up);
}
}
}
}
if($_FILES['file']['name']!=""){
upimg($_FILES['file'],"temp/");
echo "<script language=\"javascript\">";
echo "var pl=top.document.getElementById('mypic1');";
echo "pl.innerHTML=\"<img src='temp/".$file_up."' width='50' height='50' />\";";
echo "top.document.form1.action='';";
echo "top.document.form1.target='';";
echo "</script>";
echo "<meta http-equiv=\"Refresh\" content=\"0;URL=php_upload.php?d_img=".$file_up."\" />";
}
?>
<?php
if($_GET['d_img']!=""){
@unlink("temp/".$_GET['d_img']);
}
?>
|
 |
 |
 |
 |
Date :
2013-10-01 07:58:16 |
By :
359 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|