我目前有一个表单,其中上传文件如下所示:
我想让它看起来像这样:
这样做的原因是因为服务器已经有了这些文件。所以我只想在输入字段中添加 URL。但是,上传按钮也很重要,因为我们需要上传尚未在服务器中的文件。
我们如何最好地解决这个问题?
我目前有这个代码:
function wp_custom_attachment() {
wp_nonce_field(plugin_basename(__FILE__), 'wp_custom_attachment_nonce');
$html .= '<input type="file" id="wp_custom_attachment" name="wp_custom_attachment" value="" size="25" />';
echo $html;
}
我尝试了这样的方法,但最终出现了警告:
$html .= '<input type="text" value="" id="wp_custom_attachment" name="wp_custom_attachment" onclick="javascript:document.getElementById(\'file\').click();"><input id="file" type="file" name="img" onchange="ChangeText(this, \'wp_custom_attachment\');"/>';
警告:
Warning: Illegal string offset 'url' in /path/content.php on line 42
一只萌萌小番薯
相关分类