|
 |
|
นอกจากคำสั่ง @unlinkแล้วมีคำสั่งตัวไหนอีกบ้างครับที่จะลบไฟล์ที่อัพออกจากโฟนเดอร์ |
|
 |
|
|
 |
 |
|
unlink นี่หละครับ ชะงัีดแ่ล หายเกลี้ยง
|
 |
 |
 |
 |
Date :
2009-10-24 00:47:02 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ครับดูการใส่โค้ด unlink ของผมนะครับบันทัดที่52-53นะครับ,มันถูกปล่าว
Code (PHP)
<?php
session_start();
include("../../Includes/PortalConection.php");
include("../../Includes/Database.php");
$strRootpath= "../../";
include_once ("../../Includes/validsession.php");
//$strsql = "SELECT FROM news_t_newsdetails ";
// $strsql.= " WHERE id=" .SQLSafeString($tempfile);
// $objQuery = mysql_query($tempfile) or die (mysql_error());
// $objResult = mysql_fetch_array($objQuery);
// if($objResult)
// {
// if($objResult["tempfile"]!="")
// {
// @unlink("./filedata/".$objResult["tempfile"]);
// }
// }
if (!isset($_GET['action']))
{
$strAction="";
}
else
{
$strAction =QuerySafeString($_GET["action"]);
}
$conclass =new DataBase();
$strErrorMessages="";
if ($strAction=="DEL")
{
$strID= QuerySafeString($_GET["ID"]);
if (!isset($_GET['View']))
{
$strView="Active";
}
else
{
$strView= QuerySafeString($_GET["View"]);
}
if (($strID!="") && ($strID!="0"))
{
$strsql="DELETE FROM news_t_newsdetails ";
$strsql.= " WHERE id=" .SQLSafeString($strID);
$var1=$conclass->Execute ($strsql,$strErrorMessages);
if ($strErrorMessages!="")
{
$strErrorMessages = "Could not delete the news information. " .$strErrorMessages;
}else
unlink(".filedata/file_name"); // คำสั่งลบไฟล์
//@unlink("./filedata/"["tempfile"]);
// unlink("Admin/News/filedata/"); // คำสั่งลบไฟล์
}
}
else
{
$strID= QuerySafeString(strtoupper($_REQUEST["txtID"]));
$strTitle= QuerySafeString($_REQUEST["txtTitle"]);
$strNewsDescription= NewLineinHTML(QuerySafeString($_REQUEST["txtNews"]));
$strNewsDate=QuerySafeString($_REQUEST["txtNewsDate"]);
$strExpireDate=QuerySafeString($_REQUEST["txtExpireDate"]);
$strActive=QuerySafeString($_REQUEST["txtActive"]);
$strView= QuerySafeString($_REQUEST["txtView"]);
if ($strActive=="")
{
$strActive="N";
}
if (($strID !="") && ($strID!="0"))
{
$strsql="UPDATE news_t_newsdetails SET title='" . SQLSafeString($strTitle) ;
$strsql.= "',newsdescription ='" . SQLSafeString($strNewsDescription) ;
$strsql.= "',newsdate ='" . DateFormatMysql($strNewsDate) ;
$strsql.= "',expirydate ='" . DateFormatMysql($strExpireDate) ;
$strsql.= "',active='" . SQLSafeString($strActive);
$strsql.= "' WHERE id=" . SQLSafeString($strID);
$var1=$conclass->Execute ($strsql,$strErrorMessages);
if ($strErrorMessages!="")
{
$strErrorMessages = "Could not update the news information. " . $strErrorMessages;
}
}
else
{
$strsql= "INSERT INTO news_t_newsdetails(title,newsdescription,newsdate,expirydate,active";
$strTemp= " VALUES('" . SQLSafeString($strTitle) . "','" . SQLSafeString($strNewsDescription) . "','" ;
$strTemp.= DateFormatMysql($strNewsDate) . "','" . DateFormatMysql($strExpireDate) . "','" ;
$strTemp.= SQLSafeString($strActive) . "'";
$strsql.= ") " . $strTemp . ")";
$var1=$conclass->Execute ($strsql,$strErrorMessages);
if ($strErrorMessages!="")
{ $strErrorMessages = "Could not add the news. <BR>" . $strErrorMessages;}
}
}
if ($strErrorMessages=="")
{
Redirect("List.php?View=" . $strView);
}
print "<HTML><HEAD>";
include ("../../Includes/Styles.php");
print "</HEAD><BODY>";
print "<TABLE border=0>";
print "<TR><TD WIDTH=15% VALIGN=TOP>";
include_once ("../../menulist.php");
print "</TD><TD>";
print $strErrorMessages;
?>
<P> </P>
<A HREF="List.php?View=<?php print $strView;?>"> Back to List</A>
<?php
print "</TD></TR>";
print "</TABLE>";
?>
</BODY>
</HTML>
|
 |
 |
 |
 |
Date :
2009-10-24 00:57:23 |
By :
somsak84 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คำสั่ง unlink มันต้องระบุพาธไฟล์ด้วยครับ
$filedelete = "mylove.jpg";
unlink($myFile);
หรือ
unlink("../pics/mylove.jpg");
ระบุพาธให้ถูกต้อง ตรงชื่อไฟล์ ต้องมีสามสกุลด้วย หรือเรียกมาจากฐานข้อมูล
เราต้องเรียกชื่อไฟล์มาจากฐานข้อมูลก่อนว่า ชื่อไฟล์มันชื่ออะไร แล้วค่อยใส่ตรงไฟล์พาธให้ถูกต้องน่ะครับ
$myfile = $r['mypicture'];
unlink("../pics/$myfile");
ดูตัวอย่างที่ http://th.php.net/manual/en/function.unlink.php ครับผม
|
 |
 |
 |
 |
Date :
2009-10-24 05:58:30 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ครับแล้วถ้า sql ผมเป็นตาราง news_t_newsdetails เก็บพาทไฟล์ไว้ที่ newsdescription
จะเพิ่มคำสั่ง unlink ยังไงอะครับ
พี่ปลากริมและพี่ p@e ช่วยหน่อยนะครับ
|
 |
 |
 |
 |
Date :
2009-10-24 15:39:32 |
By :
somsak84 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ครับแล้วถ้า sql ผมเป็นตาราง news_t_newsdetails เก็บพาทไฟล์ไว้ที่ newsdescription
จะเพิ่มคำสั่ง unlink ยังไงอะครับ
พี่ปลากริมและพี่ p@e ช่วยหน่อยนะครับ
|
 |
 |
 |
 |
Date :
2009-10-26 22:43:22 |
By :
somsak84 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
<?php
session_start();
include("../../Includes/PortalConection.php");
include("../../Includes/Database.php");
$strRootpath= "../../";
include_once ("../../Includes/validsession.php");
if (!isset($_GET['action']))
{
$strAction="";
}
else
{
$strAction =QuerySafeString($_GET["action"]);
}
$conclass =new DataBase();
$strErrorMessages="";
if ($strAction=="DEL")
{
$strID= QuerySafeString($_GET["ID"]);
if (!isset($_GET['View']))
{
$strView="Active";
}
else
{
$strView= QuerySafeString($_GET["View"]);
}
if (($strID!="") && ($strID!="0"))
{
$strSQL = "SELECT * FROM news_t_newsdetails ";
$strSQL .= "WHERE newsdescription='".$_GET["newsdescription"]."' ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
if($objResult["files"]!="")
{
unlink("filedata/".$objResult["files"]);
}
}
$strsql="DELETE FROM news_t_newsdetails ";
$strsql.= " WHERE id=" .SQLSafeString($strID);
$var1=$conclass->Execute ($strsql,$strErrorMessages);
if ($strErrorMessages!="")
{
$strErrorMessages = "Could not delete the news information. " .$strErrorMessages;
}
}
}
else
{
$strID= QuerySafeString(strtoupper($_REQUEST["txtID"]));
$strTitle= QuerySafeString($_REQUEST["txtTitle"]);
$strNewsDescription= NewLineinHTML(QuerySafeString($_REQUEST["txtNews"]));
$strNewsDate=QuerySafeString($_REQUEST["txtNewsDate"]);
$strExpireDate=QuerySafeString($_REQUEST["txtExpireDate"]);
$strActive=QuerySafeString($_REQUEST["txtActive"]);
$strView= QuerySafeString($_REQUEST["txtView"]);
if ($strActive=="")
{
$strActive="N";
}
if (($strID !="") && ($strID!="0"))
{
$strsql="UPDATE news_t_newsdetails SET title='" . SQLSafeString($strTitle) ;
$strsql.= "',newsdescription ='" . SQLSafeString($strNewsDescription) ;
$strsql.= "',newsdate ='" . DateFormatMysql($strNewsDate) ;
$strsql.= "',expirydate ='" . DateFormatMysql($strExpireDate) ;
$strsql.= "',active='" . SQLSafeString($strActive);
$strsql.= "' WHERE id=" . SQLSafeString($strID);
$var1=$conclass->Execute ($strsql,$strErrorMessages);
if ($strErrorMessages!="")
{
$strErrorMessages = "Could not update the news information. " . $strErrorMessages;
}
}
else
{
$strsql= "INSERT INTO news_t_newsdetails(title,newsdescription,newsdate,expirydate,active";
$strTemp= " VALUES('" . SQLSafeString($strTitle) . "','" . SQLSafeString($strNewsDescription) . "','" ;
$strTemp.= DateFormatMysql($strNewsDate) . "','" . DateFormatMysql($strExpireDate) . "','" ;
$strTemp.= SQLSafeString($strActive) . "'";
$strsql.= ") " . $strTemp . ")";
$var1=$conclass->Execute ($strsql,$strErrorMessages);
if ($strErrorMessages!="")
{ $strErrorMessages = "Could not add the news. <BR>" . $strErrorMessages;}
}
}
if ($strErrorMessages=="")
{
Redirect("List.php?View=" . $strView);
}
print "<HTML><HEAD>";
include ("../../Includes/Styles.php");
print "</HEAD><BODY>";
print "<TABLE border=0>";
print "<TR><TD WIDTH=15% VALIGN=TOP>";
include_once ("../../menulist.php");
print "</TD><TD>";
print $strErrorMessages;
?>
<P> </P>
<A HREF="List.php?View=<?php print $strView;?>"> Back to List</A>
<?php
print "</TD></TR>";
print "</TABLE>";
?>
</BODY>
</HTML>
|
 |
 |
 |
 |
Date :
2009-10-26 23:10:53 |
By :
somsak84 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|