這已經差不多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" />';
後面寫下一些東西,可惜我不知道要放什麼。誰能幫我?謝謝。'