php - How to store custom field uploaded photo into database in wordpress
259
I have a custom field(file) in my pagetemplate.
<input type="file" name="head-photo" size="40" class="wpcf7-form-control form-control" id="uploadImage" aria-invalid="false" />
How can i store uploaded file(photo) in to my wordpress database?
Answer
Solution:
if you use this field to save any post detail than, you can save this field value as add_post_meta($post_id, $meta_key, $meta_value, $unique); for update update_post_meta($post_id, $meta_key, $meta_value, $prev_value);
Please check https://codex.wordpress.org/Function_Reference/add_post_meta https://codex.wordpress.org/Function_Reference/update_post_meta
Answer
Solution:
Assuming you are using a simple form with input file you can use media_handle_upload function,
Example handler on form submit