Ecommerce Shopify WordPress Discussion

Why can't I upload the file to the folder I need?

I use carbon fields to create my own fields, which I use on the add new entry page of Word press. I need to select a file in the custom field, which will then be uploaded to the folder I need when I click publish entry. But for some reason this does not happen, the file does not appear in my folder, although other fields work as they should, what could be the reason? I'm checking in the open server now. add_action('save_post', 'crb_save_post', 10, 3); function crb_save_post($post_id, $post, $update) { if (!$update && defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } $file_info = $_FILES['crb_game_files']; if ($file_info['error'] === UPLOAD_ERR_OK) { $games_folder = get_template_directory() . '/games/'; $post_folder = $games_folder . $post_id; if (file_exists($post_folder)) { $target_path = $post_folder . '/' . basename($file_info['name']); move_uploaded_file($file_info['tmp_name'], $target_path); } } } add_action('wp_after_insert_post', 'crb_after_insert_post', 10, 3); function crb_after_insert_post($post_id, $post, $update) { if ($post->post_type === 'post') { $games_folder = get_template_directory() . '/games/'; $post_folder = $games_folder . $post_id; if (!file_exists($post_folder)) { mkdir($post_folder); } } } add_action('after_setup_theme', 'crb_load'); function crb_load() { require_once(dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php'); \Carbon_Fields\Carbon_Fields::boot(); }
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.