以下是完整的php程式碼:
我的目的是要"對應MySQL裡儲存的路徑, 將指定的檔案複製至指定的目錄 "
有試過在同一目錄下複製, 完全沒問題
但使用MySQL裡的路徑時, 就錯誤,,,
想請問大大們 是錯在哪裡?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title> 對應MySQL的路徑,將指定的檔案複製至指定的目錄 </title>
</head>
<body>
<?php
mysql_connect("localhost", "root", "phpmysql") or die (" 無法連結主機 ");
mysql_select_db("IMAGE") or die (" 無法連結資料庫 ");
$sql2="select * from imagea";
$sql3=mysql_query($sql2);
while($list2=mysql_fetch_array($sql3))
{
$address=$list2['address'];
$day_and_time=$list2['day_and_time'];
}
//echo "" ."<br>";
echo "address: ".$address."<br>"; //顯現結果為"address: \new\test\ "
echo "day_and_time:".$day_and_time."<br>"; //顯現結果為"day_and_time:19920826000102 "
$oldfile=$address;//要複製的檔案
$newfile=abc.jpg;//目的檔案
$a=$address.$day_and_time.".jpg";
echo $a."<br>";//顯現結果為" \new\test\19920826000102.jpg "
$isok=copy($a,$newfile);//複製成功傳回 true,反之 false
if(isok==true)
{
echo "檔案複製完成!";//顯示成功訊息
}else{
echo "檔案複製失敗...";//顯示失敗訊息
}
?>
</body>
</html>
網頁顯現的錯誤訊息:
address: \new\test\
day_and_time:19920826000102
\new\test\19920826000102.jpg
Warning: copy(\new\test\19920826000102.jpg) [function.copy]: failed to open stream: No such file or directory in C:\AppServ\www\new\copy2.php on line 29
檔案複製完成!
This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends: 'You Say What You Like, Because They Like What You Say' - http://www.medialens.org/index.php/alerts/alert-archive/alerts-2013/731-you-say-what-you-like-because-they-like-what-you-say.html