0
$url="http://www.source.com/top";
$destination=fopen("/var/www/vhosts/domain.com/httpdocs/temp/" . date('m-d-Y'),"w");
echo "dest=$destination<br>";
echo "url=$url<br>";
$source=fopen($url,"r");
$maxsize=5000000000;
$length=0;
while (($a=fread($source,1024))&&($length<$maxsize))
{
$tmpfile=$tmpfile . $a;
$length=$length+1024;
}
fwrite($destination,$tmpfile);
fclose($source);
fclose($destination);
上面的PHP源代碼就像我的共享主機帳戶上的魅力一樣工作。但是,它無法在我的專用Linux Centos機器上寫入文件。在這臺Centos機器中,源$ url可以正常讀取,但是這行:
$destination=fopen("/var/www/vhosts/domain.com/httpdocs/temp/" . date('m-d-Y'),"w");
無法在Linux中寫入文件。我試圖運行在linux下root用戶上面的代碼運行(如PHP文件name.php),並能創建文件卻無法讀取源文件:
$destination=fopen("/var/www/vhosts/domain.com/httpdocs/temp/" . date('m-d-Y'),"w");
我得到一個403錯誤。我對這臺Linux Centos機器發生了什麼感到困惑。就像我之前在Centos中發佈的那樣,我在提交相同頁面之間出現Session variables return empty的問題。任何幫助表示讚賞。
@ user914425這可能是一些與你的文件權限。嘗試'chmod 777 -R/var/www/vhosts/domain.com/httpdocs/temp /'並重試。一旦您發現問題 – 2012-02-22 03:26:17
讓我更改爲777的文件夾權限,請將權限切換爲更安全。 – user914425 2012-02-22 17:14:27