iT邦幫忙

0

php mkdir權限問題

php
chan15 2010-01-05 23:53:5115082 瀏覽

我今天用了mkdir成功建立了一個權限為777的目錄
但卻無法上傳任何東西上去,空間商是說,因為用function建立的話,擁有者為apache
用FTP建立目錄的話,擁有者為我的帳號,我的帳號建立的東西才有放置的權限
這個問題有解嗎?無解的話mkdir的存在似乎變得沒有意義,建立目錄不都是為了放東西上去嗎

fillano iT邦超人 1 級 ‧ 2010-01-06 10:21:52 檢舉
所以你是用php來mkdir然後用ftp上傳?
chan15 iT邦新手 2 級 ‧ 2010-01-08 16:12:20 檢舉
不是
用FTP權限開帳號,就可以順利用PHP upload東西了。
chan15 iT邦新手 2 級 ‧ 2010-01-08 16:12:40 檢舉
講錯,應該是說用FTP權限開資料夾。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
6
marshuang
iT邦新手 1 級 ‧ 2010-01-06 00:00:42
最佳解答

有chgrp 屬性嗎?

2
moni
iT邦新手 4 級 ‧ 2010-01-06 23:33:41

您是用php程式上傳檔案還是用FTP傳到該目錄?

用PHP建立的目錄,要上傳只能用PHP來傳,或是您可以問問空間商是否有用suPHP或CGI模式的主機,請他幫您換過去。

chan15 iT邦新手 2 級 ‧ 2010-01-07 00:28:24 檢舉

用php建立目錄
用php upload檔案

2
jackwan
iT邦研究生 4 級 ‧ 2010-01-07 15:28:55

權限 777 不管擁有者是誰應該是都可寫入才對,
使用 ls -l 查看目錄權限是否 777 (drwxrwxrwx).

chan15 iT邦新手 2 級 ‧ 2010-01-07 17:22:56 檢舉

後來用了這個方法

<pre class="c" name="code">
<?php
$basePath = 'httpdocs/';
$serverPosition = 'www.xxx.com.tw';
$serverAccount = 'abc';
$serverPassword = 123;
if (!is_dir($dir)) {
	$ftpDir = $basePath . $dir;
	$connection = ftp_connect($serverPosition);
	$login_result = ftp_login($connection, $serverAccount, $serverPassword);
	if(ftp_mkdir($connection, $ftpDir)) {
		ftp_site($connection, "CHMOD 777 $ftpDir");
	}
	ftp_close($connection);
}
?>
fillano iT邦超人 1 級 ‧ 2010-01-07 19:49:18 檢舉

chmod 777還不行,不禁懷疑業者的系統是不是把selinux打開了。

我要發表回答

立即登入回答