Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 移动\u上载的\u文件与WordPress有问题_Php_Wordpress - Fatal编程技术网

Php 移动\u上载的\u文件与WordPress有问题

Php 移动\u上载的\u文件与WordPress有问题,php,wordpress,Php,Wordpress,尝试添加一个文件上传到WordPress,到目前为止,除了move_upload_文件外,一切都运行良好 <input type="file" name="attachment" id="attachment"> 你有没有试过回显WP_CONTENT_DIR,看看会得到什么?或者做一个var\u转储(is\u dir(WP\u CONTENT\u dir./uploads/cv/'.basename($\u FILES['attachment']['name']))。也在$\u F

尝试添加一个文件上传到WordPress,到目前为止,除了move_upload_文件外,一切都运行良好

<input type="file" name="attachment" id="attachment">

你有没有试过回显WP_CONTENT_DIR,看看会得到什么?或者做一个
var\u转储(is\u dir(WP\u CONTENT\u dir./uploads/cv/'.basename($\u FILES['attachment']['name']))
。也在$\u FILES数组上做一个打印,查看它返回的实际错误号并与之关联:可能会有帮助。请让我知道每个人的结果,除非你能弄清楚。

添加这个
error\u报告(E|u ERROR | E|WARNING | E| PARSE);
然后您会得到一个错误日志谢谢,这样做了,但仍然没有创建错误日志,所以我不确定如何调试它,将编辑以发布更完整的代码。
if (!move_uploaded_file($_FILES["attachment"]["tmp_name"],WP_CONTENT_DIR .'/uploads/cv/'.basename($_FILES['attachment']['name'])))
        {
            $return['error'] = true; $return['error_message'] = __('File could not be uploaded', 'btoa').'<br />';

        }
<form action="<?php echo home_url() ?>" method="post" id="enquiry-form" enctype="multipart/form-data">

            <p><small class="error" style="margin-top: 15px; display: none;"></small></p>

            <p><input type="text" value="<?php _e('Your name', 'btoa'); ?>" name="name" id="enquiry-name" onfocus="if(jQuery(this).val() == '<?php _e('Your name', 'btoa'); ?>') { jQuery(this).val(''); }" onblur="if(jQuery(this).val() == '') { jQuery(this).val('<?php _e('Your name', 'btoa'); ?>'); }" /></p>

            <p><input type="text" value="<?php _e('Email address', 'btoa'); ?>" name="email" id="enquiry-email" onfocus="if(jQuery(this).val() == '<?php _e('Email address', 'btoa'); ?>') { jQuery(this).val(''); }" onblur="if(jQuery(this).val() == '') { jQuery(this).val('<?php _e('Email address', 'btoa'); ?>'); }" /></p>
            <p><label for="file">Upload your CV/Resume:</label></p>
            <p style="margin-bottom:0;"><input type="file" name="attachment" id="attachment"></p>

            <p><textarea name="message" id="enquiry-message" cols="" rows="4" onfocus="if(jQuery(this).val() == '<?php _e('Message', 'btoa'); ?>') { jQuery(this).val(''); }" onblur="if(jQuery(this).val() == '') { jQuery(this).val('<?php _e('Message', 'btoa'); ?>'); }"><?php _e('Message', 'btoa'); ?></textarea></p>

            <p><input type="submit" class="button-primary" value="<?php _e('Send', 'btoa'); ?>" /></p>

            <div class="clear"></div>
            <!-- /.clear/ -->

            <div class="error-message"></div>

            <div class="thank-you hidden">

                <p><?php _e('Thank you! Your message has been successfully sent.', 'btoa'); ?></p>

            </div>

        </form>
//// IF EMAIL IS VALID
    if($return['error'] == '') {

        /// GETS OTHER VARS
        $name = isset($_POST['email']) ? trim($_POST['name']) : '';
        $the_message = isset($_POST['message']) ? trim($_POST['message']) : '';
        $post_id = isset($_POST['post_id']) ? trim($_POST['post_id']) : '';

        //// NOW WE GET OUR SPOT AND THE USER
        $spot = get_post($post_id);
        $user = get_user_by('id', $spot->post_author);

        //// STARTS OUR RECIPIENT ARRAY
        $to = $user->user_email;

        //// HEADERS
        $headers = 'From: '.get_bloginfo('name').' <'.get_option('admin_email').'>'."\r\n".
        'Reply-To: '.$email;

        $subject = sprintf2(__('%site_name Contact: %spot_name', 'btoa'), array('site_name' => get_bloginfo('name'), 'spot_name' => $spot->post_title));
        if (!move_uploaded_file($_FILES["attachment"]["tmp_name"],WP_CONTENT_DIR .'/uploads/cv/'.basename($_FILES['attachment']['name'])))
        {
            $return['error'] = true; $return['error_message'] = __('File could not be uploaded', 'btoa').'<br />';
            error_reporting(E_ERROR | E_WARNING | E_PARSE);

        }


$attachments = array(WP_CONTENT_DIR ."/uploads/cv/".basename($_FILES['attachment']['name']));
        add_filter( 'wp_mail_content_type', 'my_custom_email_content_type' );
        function my_custom_email_content_type() {
return 'text/html';
}
        $message = sprintf2(__("Dear %author,

%user (email: %email) has sent you a message via %site_name:

-----

%message", 'btoa'), array(

            'author' => $user->display_name,
            'user' => $name,
            'email' => $email,
            'site_name' => get_bloginfo('name'),
            'attachment' => $attachments,
            'message' => $the_message

        ));



        //// SENDS OUT OUR EMAIL
        if(!wp_mail($to, $subject, stripslashes($message), $headers, $attachments)) {

            $return['error'] = true; $return['error_email'] = sprintf2(__('There was a problem sending your enquiry. Please email us directly at %site_email', 'btoa'), array('site_email' => get_option('admin_email')));

        } else { $return['success'] = stripslashes($headers); }

    }

    echo json_encode($return);
    exit;

}
// Enable WP_DEBUG mode
define('WP_DEBUG', true);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);

// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define('SCRIPT_DEBUG', true);