所以我有一個問題。當某人在我正在構建的網站上註冊一個帳戶時,他們會進入設置頁面,在該頁面上傳個人資料照片。我正在使用mkdir自動創建一個子文件夾,其用戶名可以正常工作,並且CHMOD在該子文件夾中爲777。我遇到的問題是圖像沒有被移動到指定的子文件夾,但它會進入「uploads」文件夾,它是父目錄。我的文件沒有被移動到指定的和新創建的文件夾使用mkdir
希望我沒有困惑任何人,但我真的需要幫助。
下面是我寫的這個腳本。
============================================== =================================
require_once('../admin/includes/config.php');
$uploaded_file = $_REQUEST['uploaded_file'];
$member_id = $_REQUEST['member_id'];
$name = $_REQUEST['name'];
$location = $_REQUEST['location'];
$hobbies = $_REQUEST['hobbies'];
$hobby = $_REQUEST['hobby'];
// using member_id, extract the username from the members table so we can auto create a sub-directory for the images
$result = mysql_query("SELECT username FROM members WHERE member_id = '$member_id'");
while($row = mysql_fetch_array($result))
{
$username = $row['username'];
}
// unmask to change CHMOD of newly created sub directory to 777
$old_mask = umask(0);
//Create directory with member's username
$madedir = mkdir('../admin/uploads/'.$username.'', 0777) /*== TRUE ? 1 : 0*/;
umask($old_mask);
// Assign the directory the file is going to be uploaded to
$uploaddir = '../admin/uploads/'.$username.'';
// Get the file name
$file_name = $_FILES['uploaded_file']['name'];
// Upload file to assigned directory with file name
$uploadfile = $uploaddir . basename($_FILES['uploaded_file']['name']);
// If the file has been uploaded, run this script
if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $uploadfile)) {
echo "Success";
} // end if
else {
echo "there was an error uploading your file";
}
是這樣寫的什麼語言? – 2010-07-13 15:57:31
看起來像Perl? – 2010-07-13 16:00:09
更像PHP給我 – 2010-07-13 16:02:18