質問: insert_attachment($file,$post_id); // $newupload returns the attachment id of the file that // was just uploaded. do whatever you want with that now. } } 使用したアップロードフォーム...<form method="post" action="#" enctype="multipart/form-data" > <input type="file" name="an_uploaded_attachment"> <input type="file" name="another_uploaded_attachment"> <input type="file" name="yet_another_uploaded_attachment"> <input type="submit"> <form>
回答: ヘッダの$post_idを$post->idに変更します。// set $post_id to the id of the post you want to attach // these uploads to (or 'null' to just handle the uploads // without attaching to a post) if ($_files) { foreach ($_files as $file => $array) { $newupload = insert_attachment($file,$post->id); // $newupload returns the attachment id of the file that // was just uploaded. do whatever you want with that now. } }