我正在为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