Upload File Through PHP, Error or Empty attachment.
-
Hey,
I’m working on a script that can post stuff from outside wordpress.
However the following ain’t working.$post = array( "post_title" => $posttitle, "post_content" => $content, "post_status" => "draft", "post_author" => 1, "post_category" => array(9, 10), "tags_input" => array($show, $title, 'TV Show'), "post_type" => "post", ); $post_id = wp_insert_post( $post ); $image = file_get_contents($image); file_put_contents("/data/www/blogfreestuff/public_html/tools/hulu/image.jpg", $image); $image = "/data/www/blogfreestuff/public_html/tools/hulu/image.jpg"; echo $image; $attachment = array( "post_title" => $show . " - " . $title . "(Thumb)", "post_content" => "", "post_status" => "draft"); $id = wp_insert_attachment($attachment , $image, $post_id ); wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $image ) );It sais wp_generate_attachment_metadata doesn’t exist, so I included the file that contained the function, the error is gone, but the attachment gets inserted without image.
So can anyone help me out ?
Thanks, Xeross
Edit: I forgot i’m using wpmu
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Upload File Through PHP, Error or Empty attachment.’ is closed to new replies.