Wordpress 上传完成后,如何使用uploadify保存上传文件的路径?
我在stackoverflow浏览这里寻找答案已经快两个小时了。我已经设法使我的上传文件功能良好,通过阅读这里的一些答案。但这次没办法。我真的需要问一下上传后如何保存上传文件的路径。看,我在wordpress插件中使用uploadify。我所做的是将上传的文件(.pdf)保存到我的目录中的一个特定文件夹中。然后我想在发布帖子时保存保存的文件的路径。所以从技术上讲,上传后,我希望上传文件的路径在帖子的某个地方,这样当我发布帖子时,路径也会保存在数据库中。这可能吗 这是我插件中的代码片段Wordpress 上传完成后,如何使用uploadify保存上传文件的路径?,wordpress,uploadify,Wordpress,Uploadify,我在stackoverflow浏览这里寻找答案已经快两个小时了。我已经设法使我的上传文件功能良好,通过阅读这里的一些答案。但这次没办法。我真的需要问一下上传后如何保存上传文件的路径。看,我在wordpress插件中使用uploadify。我所做的是将上传的文件(.pdf)保存到我的目录中的一个特定文件夹中。然后我想在发布帖子时保存保存的文件的路径。所以从技术上讲,上传后,我希望上传文件的路径在帖子的某个地方,这样当我发布帖子时,路径也会保存在数据库中。这可能吗 这是我插件中的代码片段 /* Di
/* 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);
}
/*显示框内容,即基金的下拉列表*/
功能wnm_pengana_investor_upload_investor_box($post){
/*使用nonce进行验证*/
wp_nonce_字段(plugin_basename(uuu FILE_uuu),“wnm_pengana_funds_noncename”);
echo';
echo“一次上载一个或多个文件”;
回声';
回声“
”;
}
/*保存帖子时,会保存自定义数据*/
函数wnm_pengana_save_investor_upload_box($post_id){
/*验证这是否是一个自动保存例程。如果是,我们的表单尚未提交,因此我们不想做任何事情*/
if(已定义('DOING_AUTOSAVE')&&DOING_AUTOSAVE)
返回;
/*验证这是否来自我们的屏幕并经过适当授权,因为save_post可以在其他时间触发*/
如果(!wp\u verify\u nonce(isset($\u POST['wnm\u pengana\u funds\u noncename')),插件\u basename(\uuuuu FILE\uuuuu)))
返回;
//检查权限
如果('page'=$\u POST['POST\u type'])){
如果(!当前用户可以('edit_page',$post_id))
返回;
}否则{
如果(!当前用户\u可以('edit\u post',$post\u id))
返回;
}
//好的,我们已通过身份验证:我们需要查找并保存数据
$mydata=$\u POST['investor\u file\u upload'];
更新发布元数据($post\u id,'uploaded\u forms\u path',$mydata);
}
当前,发布后,postmeta上传的表单路径将添加到postmeta表中,但它是空的。我想我需要在'echo'后面加上一些东西代码>
可悲的是,我不知道该放什么。有人能帮我吗?谢谢。谢谢大家。似乎没有人想回答,所以我不得不拼命地为自己找到答案
好的,我所做的是,保存文件后,从文件uploadify.php,如果文件上传成功,我返回$newTargetFile
,这样使用uploadify的onUploadSuccess事件,我可以显示$newTargetFile
的值,这是上传文件的路径。然后,我将其指定为隐藏的
的值,因此当发布帖子时,隐藏输入的数据将作为postETA数据发布。:)