WordpressディレクトリのuploadsフォルダにあるXMLファイルに書き込もうとしています。このXMLは、クライアントが作成したカスタムpost_typeを使用して新しい投稿を更新または作成するたびに更新する必要があります。 ?ここでWordpressでfopenを使用してXMLファイルに書き込む
はコードです:「ファイルを開くことができません」
<?
add_action('save_post', 'producers_xml');
function producers_xml(){
if ($_POST['post_type'] == 'producer')
{
$xml = new SimpleXMLElement('<xml/>');
$producers = get_posts(array('post_type'=>'producer', 'numberposts'=>-1));
$xml->addChild('producers');
foreach($producers as $i=>$producer){
$name = get_the_title($producer->ID);
$owner = get_post_meta($producer->ID, '_producer_contact_name', true);
$phone = get_post_meta($producer->ID, '_producer_phone', true);
$fax = get_post_meta($producer->ID, '_producer_fax', true);
$email = get_post_meta($producer->ID, '_producer_email', true);
$website = get_post_meta($producer->ID, '_producer_website', true);
$address = get_post_meta($producer->ID, '_producer_address', true);
$xml->producers->addChild('producer');
$xml->producers->producer[$i]->addChild('name', $name);
$xml->producers->producer[$i]->addChild('owner', $owner);
$xml->producers->producer[$i]->addChild('phone', $phone);
$xml->producers->producer[$i]->addChild('fax', $fax);
$xml->producers->producer[$i]->addChild('email', $email);
$xml->producers->producer[$i]->addChild('website', $website);
$xml->producers->producer[$i]->addChild('address', $address);
}
$file = '../../../uploads/producers.xml';
$open = fopen($file, 'w') or die ("File cannot be opened.");
fwrite($open, $xml->asXML());
fclose($open);
}
} >
私が午前問題は、それが私に与え続けていることです私が提供したエラーです。私のアップロードフォルダ(およびすべての同梱のアイテム)にはフルアクセス権があります(777)。私は自分のコードをローカルでテストしていますが、動作しますが、リモートサーバ上でそのファイルを開くことができません。私はそれにルートアクセス権を持っていないので、httpdocsの前に何かのパーミッションを変更することはできません。
fopenがサーバー上で有効になっていることにも言及してください。
EDIT: allow_url_fopenは有効ですが、allow_url_includeは無効です。
私の問題は何ですか?他のチェックが見ると並ん
おかげ
をそれが働きました。後の視点では、その解決策はとても簡単なようです。ありがとう! – jasonaburton