我正在爲Wordpress網站創建用戶提交的發佈工具。從URL上傳圖片到Wordpress
用戶可以輸入圖片網址,我希望將其添加到帖子以及其他內容,如標題和帖子內容。
我有這個工作使用常規圖像附件。我創建的帖子,然後再連接使用該腳本形象:
$files = $_FILES['upload_attachment'];
$file = array(
'name' => $files['name'],
'type' => $files['type'],
'tmp_name' => $files['tmp_name'],
'error' => $files['error'],
'size' => $files['size']
);
$_FILES = array("upload_attachment" => $file);
foreach ($_FILES as $file => $array) {
$newupload = insert_attachment($file,$userPost);
}
可是我該怎麼辦使用insert_attachment()
或類似,但具有URL是一回事嗎?
http://stackoverflow.com/questions/2003996/how-can-i-upload-an-image-from-a-url-in-php – mittmemo 2012-08-06 17:06:56