|
|
|
แนบไฟล์แล้ว ข้อมูลใน textbox ไม่หายทำไงครับ เวลาลบไฟล์แนบข้อมูลก็หายไปด้วยครับบบบบบบบบ |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
$Userid123=$_SESSION["idusersession"];
$titlehead="i E-Doc";
?>
<html>
<head>
<title>Ṻä¿Åì</title>
<style>
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
<link href="../css/style1.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor='#BADBF3'>
<form action="attachfile1.php" method="post" ENCTYPE="multipart/form-data" name='addfile' onSubmit="return checkattach()">
<table width="100%" border=0 CELLPADDING=0 CELLSPACING=0 bgcolor='#BADBF3'>
<tr>
<td align="center" valign="middle" class='style02' colspan=2>àÅ×Í¡ä¿Åì :
<input type="file" name="file" id="file">
<input type="hidden" name="upload" value=1>
<input type="hidden" name="iddocedit" value=<?=$iddocedit?>>
<!--<input name="n" type="text" id="n1" value="<?=$n?>"<input type="submit" name="Submit" value="xxx" onClick="opener.docadd.submit()">
<input type="submit" name="Submit" value="xxx" onClick="opener.location.reload()">
<input type="submit" name="Submit" value="Submit" onClick="opener.document.all.name2.value=document.all.n1.value;">-->>
</td>
</tr>
<tr><td colspan=2 align='center' class='style02'><font color='red'>( * ¢¹Ò´ä¿Åì äÁèà¡Ô¹ 2 MB)</font></td></tr>
<tr><td colspan=2 align='center' class='style02'><INPUT TYPE="radio" NAME="copyed" value=1 checked> »ÑéÁÊÓà¹Ò <INPUT TYPE="radio" NAME="copyed" value=2> äÁè»ÑéÁÊÓà¹Ò</td></tr>
<tr><td colspan=2 align='center' bgcolor="#479BEF"><input type="submit" value="µ¡Å§"></td></tr>
</table>
</form>
</body>
</html>
<?php
include("../function.php");
include("../Startcon.inc");
if($upload==1){
$SAVE_PATH = $_SERVER['DOCUMENT_ROOT']."/worksystem/jobs_nct/fileattach/";
//$SAVE_PATH="D:\webserver\home\worksystem\e-doc\doc\\";
//echo $SAVE_PATH;
//echo $file;
$realname="pic".date('dmYhis');
$realnameftle="files".date('dmYhis');
/////////////////////////
$attachsize=$_FILES["file"]["size"];
$attachtype=$_FILES["file"]["type"];
if(isset($_FILES["file"])){
// echo "test";
if($_FILES["file"]["size"]>0){
if(!file_exists($SAVE_PATH)) mkdir($SAVE_PATH); //ÊÃéÒ§ Folder »ÅÒ·ҧàÁ×èÍäÁ辺
if(isImage($_FILES["file"])){ //µÃǨÊͺÇèÒà»ç¹ä¿ÅìÃÙ»ÀÒ¾
//àÃÕ¡¿Ñ§¡ìªÑè¹ Resize
if($newfilename = uploadResizeTo($_FILES["file"], $SAVE_PATH, $realname,1500,1500)){
if($copyed==1){
switch($attachtype){
case "image/pjpeg" :
case "image/jpeg" :
$imgcreate ="imagecreatefromjpeg";
$image01="imagejpeg";
break;
case "image/gif":
$imgcreate ="imagecreatefromgif";
$image01="imagegif";
break;
case "image/png":
case "image/x-png":
$imgcreate = "ImageCreateFromPNG";
$image01="imagePNG";
break;
case "image/bmp":
$imgcreate = "ImageCreateFromWBMP";
$image01="imageWBMP";
break;
default:
return(false);
}
$myImage = $imgcreate('fileattach/'.$newfilename);
$myCopyright = imagecreatefromgif('../images/copy.gif');
$destWidth = imagesx($myImage);
$destHeight = imagesy($myImage);
$srcWidth = imagesx($myCopyright);
$srcHeight = imagesy($myCopyright);
$destX = ($destWidth - $srcWidth) / 1;
$destY = ($destHeight - $srcHeight) / 1;
$white = imagecolorexact($myCopyright, 255, 255, 255);
//echo $white;
imagecolortransparent($myCopyright,-200);
imagecopymerge($myImage, $myCopyright, $destX, $destY, 0, 0, $srcWidth, $srcHeight, 50);
$image01($myImage,"fileattach/".$newfilename);
imagedestroy($myImage);
imagedestroy($myCopyright);
}
if($iddocedit==null || $iddocedit==""){
$sqlattactinsert="insert into tblworkonline_tempattachfiles_nct(name_workonline_tempattachfiles,tempid_user) values('$newfilename','$Userid123')";
}
else{
$sqlattactinsert="insert into tblworkonline_attachfiles_nct(name_workonline_attachfiles,id_user,id_workonline) values('$newfilename','$Userid123','$idworkedit')";
}
// echo $sqlattactinsert.'<br>';
$result=mysql_query($sqlattactinsert);
if( $result){
?>
<script language="JavaScript">
opener.jobsadd.submit();
</script>
<?
}
// echo $newfilename;
}else echo 'äÁèÊÒÁÒöÍѾâËÅ´ä´é';
}else{
$name1=$HTTP_POST_FILES['file']['name'];
$ext = end(explode(".", $name1));
$newrealname=$realnameftle.'.'.$ext;
copy($_FILES['file']['tmp_name'],$SAVE_PATH.''.$newrealname);
if($iddocedit==null || $iddocedit==""){
$sqlattactinsert="insert into tblworkonline_tempattachfiles_nct(name_workonline_tempattachfiles,tempid_user) values('$newfilename','$Userid123')";
}
else{
$sqlattactinsert="insert into tblworkonline_attachfiles_nct(name_workonline_attachfiles,id_user,id_workonline) values('$newfilename','$Userid123','$idworkedit')";
}
// echo $sqlattactinsert.'<br>';
$result=mysql_query($sqlattactinsert);
if( $result){
?>
<script language="JavaScript">
opener.jobsadd.submit();
</script>
<?
}
//echo '¡ÃسÒãªéä¿ÅìÃÙ»ÀÒ¾à·èÒ¹Ñé¹';
}
}else{
echo '¡ÃسÒàÅ×Í¡ä¿ÅìṺ';
}
}
////////////////////////
}
?>
<script language="JavaScript">
<!--
function checkattach()
{
var v0 = document.addfile.file.value;
if (v0.length==0)
{
alert("àÅ×Í¡ä¿ÅìṺ!!");
document.addfile.file.focus();
return false;
}
else
return true;
}
</script>
Tag : PHP
|
|
|
|
|
|
Date :
2011-05-13 10:54:29 |
By :
mab_tor |
View :
1068 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ
|
|
|
|
|
Date :
2011-05-18 16:14:20 |
By :
mab_tor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|