hi i am upload file from front-end but now code get only image attachment id i want get image url.
function agp_process_woofile($file, $post_id){
if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$attachment_id = media_handle_upload($file, $post_id);
add_post_meta($post_id, '_file_paths', $attachment_id);
$attachment_data = array(
'ID' => $attachment_id,
'post_excerpt' => $caption
);
wp_update_post($attachment_data);
return $attachment_id;
}
See attachment_id i want get url from this function and update that url to “_file_paths” post meta
For upload image in frontend just create simple post form
After submit form upload image as attachment in wordpress media as below.
hi found solution so sharig with you guys 🙂
Use the default wordpress function wp_handle_upload please refer
http://codex.wordpress.org/Function_Reference/wp_handle_upload
here my example code :
upload.html
upload.php
upload.js `