这已经差不多2个小时,我一直在这里浏览stackoverflow寻求答案。通过在这里阅读一些答案,我设法使我的上传文件功能良好。但这一次不能得到帮助。我真的需要询问如何在上传后保存上传文件的路径。请参阅我在wordpress插件中使用uploadify。我所做的就是将上传的文件(确切地说是.pdf)保存到我的目录中的特定文件夹中。然后,我想要的是在发布帖子时保存保存文件的路径。所以在技术上,在上传之后,我希望在帖子的某处有上传文件的路径,这样当我发布帖子时,路径也将被保存在数据库中。这甚至有可能吗?上传完成后如何使用uploadify保存上传文件的路径?
这是我的代码片段在我的插件,
/* Displays the box content which is the dropdown list of Funds */
function wnm_pengana_investor_upload_investor_box($post) {
/* Use nonce for verification */
wp_nonce_field(plugin_basename(__FILE__), 'wnm_pengana_funds_noncename');
echo '<p class="uploadify_container">';
echo '<label style="margin-left: 15px;" for="investor_file_upload">Upload one or more files at once.</label>';
echo '<input type="file" name="investor_file_upload" id="investor_file_upload" />';
echo '</p>';
}
/* When the post is saved, saves our custom data */
function wnm_pengana_save_investor_upload_box($post_id) {
/*verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything */
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
/* verify this came from the our screen and with proper authorization,because save_post can be triggered at other times */
if (!wp_verify_nonce(isset($_POST['wnm_pengana_funds_noncename']), plugin_basename(__FILE__)))
return;
// Check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id))
return;
} else {
if (!current_user_can('edit_post', $post_id))
return;
}
// OK, we're authenticated: we need to find and save the data
$mydata = $_POST['investor_file_upload'];
update_post_meta($post_id, 'uploaded_forms_path', $mydata);
}
目前公布的情况下,postmeta uploaded_forms_path将在postmeta表中添加,但它是空的。我想我需要在`echo '<input type="file" name="investor_file_upload" id="investor_file_upload" />';
后面写下一些东西,可惜我不知道要放什么。谁能帮我?谢谢。'