だから私は問題を抱えています。私が構築しているサイトで誰かがアカウントにサインアップすると、プロフィール写真をアップロードできる設定ページに移動します。mkdir を使用して、正常に機能しているユーザー名でサブフォルダーを自動作成しています。そのサブフォルダーの CHMOD は 777 です。私が抱えている問題は、画像が指定されたサブフォルダーに移動されていないことですが、親ディレクトリである「アップロード」フォルダーに移動しています。
誰も混乱させていないことを願っていますが、本当に助けが必要です.
以下は、これを行うために私が書いたスクリプトです。
================================================== =============================
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";
}