After two days looking for the solution and fighting with the code, I found the solution:
As I suspected, the problem was reading the file ($image_data = file_get_contents($image);
).
The first error was not included in the form enctype =" multipart / form-data "
to send files and data simultaneously.
The second error was that images are not loaded by $_POST, if not the global variable $_FILES (In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES).
And the last error was that we have to move the file to the directory uploads to read it from there with move_uploaded_file( $_FILES['imagen-promociona']['tmp_name'], $uploadfile )
I hope at least help others.
Thanks
Related Posts:
- How I upload, save and set a featured image from my frontend?
- Trying to save custom post type from frontend partially working
- Assign category to front end post
- Submit post and upload image from front-end
- How to set a custom post type to not show up on the front end
- Front end post editing using a form
- Get post ID from wp_insert_post()
- WP insert post and custom taxonomy
- Add custom post type items from frontend
- Front end registration/login & publish/update 1 custom post
- How do I programmatically add items of content to a custom post type?
- Not Able to Insert Taxonomy Term Using wp_insert_post()
- List custom post types in dropdown
- Reason action hook won’t work with update_post_meta from frontend form? Alternative?
- front end radio custom taxonomy with custom post type
- wp_insert_post custom taxonomy
- Front end post form won’t post categories to custom post type
- How can I programmatically save data into custom fields that contain serialized data?
- What hook should be used to programmatically create a post only when master post is updated?
- Create and edit posts from front end
- Make custom post type display as a page
- Frontend Form for Custom Post Type
- WordPress tax_input only if logged in
- Upload Image from Front End and Resize
- Frontend posting – everything saves other than checkboxes?
- Programmatically adding posts
- I am having a problem with form updating/editing WordPress post on the frontend
- WordPress Create Post from front-end
- Is it possible to create a post using a metabox?
- How Can I Set the Post Author of a Post I Just Created With PHP?
- How to auto increment post title & post slug field?
- Auto-generated posts not showing in backend (but being counted!)
- wp_insert_post generates endless posts
- wp_set_object_terms() not adding new term to custom post and custom taxonomy
- How to restrict CPT post’s fronted view only for specific user roles?
- How to save custom taxonomy from front end post submission
- create parent post using wp_insert_post
- Insert Custom Post Type data from the front-end by a user
- Crafting WP_Query array, sort by date
- Posting to a Custom Post Type from front end – user generated content
- Cron job for creating posts not excecuting properly
- How to get the upcoming post ID from front end?
- How to checked selected category checkbox when my custom post inserted from frontend
- How to make front end form only accept certain values
- Post author for revision not being set on update/insert
- Add CPT values to Database
- Custom Post Type & Meta Box – Displaying meta box information on front end?
- How To Import CPT With Only Few TEXT ACF Fields From Front End?
- Why cant I add a custom post type to a custom taxonomy?
- wp_insert_post wrong post type [closed]
- Submitting Custom Post Types with custom fields from Front-end form
- Programatically inserted posts not showing in Posts Table
- Is it possible to add posts and images (auto resize) for custom post types with a script?
- How to properly delete custom post type posts programmatically
- Update post if exist from PHP
- WordPress hook which triggers on post import
- Get id from metabox dropdown
- How to handle new post from API request?
- Get admin area editor in frontend
- How to handle this specific case of custom post type?
- Better approach for a WordPress Inventory
- Display custom meta on page that has been check in custom post type
- Update ACF fields on a frontend form? [closed]
- insert image with custom post type
- importing table data to custom post type
- How can I get some of a posts meta data whilst it is still inserting?
- Add term for custom taxonomy from front end
- Post visibility option to theme front-end for author to select?
- display custom portfolio tags
- Plugin needed to allow subscribers to post articles on the front end without admin approval [closed]
- How to create Custom image post?
- Front-end Image Upload to Custom Meta Box
- See if the email exists or not
- WP_Insert_Post creating duplicate posts when logged in
- wp_insert_post from XML feed only inserting first post
- Preview url not working outside wp-admin
- What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
- How do I find out which (page) template file my custom child post is looking for?
- wp_insert_post deleting previous post custom meta
- Change custom post taxonomy values from front-end
- Published page but it is page not found
- How to insert post 6 times after user register like ask.fm
- wp_insert_post() creates duplicates with ‘post_status’ => ‘publish’
- Saving Child Terms on front end not setting parent
- WordPress Front-End user restricted taxonomies
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Front End users account with lots of user Roles (not Woocommerce)
- automatic creation of custom post type articles
- Show “Republished” badge when Post Date is manipulated
- Getting Custom post category from Form
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Add a meta to custom post type which corresponds to a particular taxonomy
- Generate slug and meta data if meta field is empty
- Extensive search filtering and results->PDF in the front-end
- Front end page submission form does not attach custom post type
- wordpress form processing to custom post type not working
- Issue with permalinks for custom post type
- Front end Submit not posting to Custom Post type
- install.php Custom Taxonomy Term not being added to custom post