電子メールからサーバーに添付ファイルを保存しようとすると、これまでのところスクリプトは正常に動作しますが、wp ルート フォルダーにファイルが保存されます。
foreach ($attachments as $key => $attachment) {
$name = $attachment['name'];
$contents = $attachment['attachment'];
file_put_contents($name, $contents);
}
ファイルを別のフォルダに保存するにはどうすればよいですか?
このコードを試してみましたが、うまくいきませんでした。
foreach ($attachments as $key => $attachment) {
$name = $attachment['name'];
$contents = $attachment['attachment'];
file_put_contents(get_stylesheet_directory_uri() . '/email_attachments/' . $name, $contents);
}
何か案が?