Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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 wordpress上传文件错误_Php_Wordpress_File Upload - Fatal编程技术网

Php wordpress上传文件错误

Php wordpress上传文件错误,php,wordpress,file-upload,Php,Wordpress,File Upload,我有这个上传文件系统在wordpress,一切都很好,但文件不会进入文件夹。以下是我现在拥有的: if ( ! function_exists( 'wp_handle_upload' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } // Change your upload directory function my_upload_dir(){ return PLUGIN_DIR . '/uploa

我有这个上传文件系统在wordpress,一切都很好,但文件不会进入文件夹。以下是我现在拥有的:

if ( ! function_exists( 'wp_handle_upload' ) ) {
    require_once( ABSPATH . 'wp-admin/includes/file.php' );
}

// Change your upload directory
function my_upload_dir(){
    return PLUGIN_DIR . '/uploads/';
}

// Register our path override.
add_filter( 'upload_dir', 'my_upload_dir' );

// Set where to get the file from
$uploadedfile = $_FILES["attach"];
$upload_overrides = array( 'test_form' => false );

// Do the file move
$movefile = wp_handle_upload($uploadedfile, $upload_overrides);

// Set everything back to normal.
remove_filter( 'upload_dir', 'my_upload_dir' );

// Return an error if it couldn't be done
if (!$movefile || isset( $movefile['error'])) {
    echo $movefile['error'];
}
它似乎工作正常(没有错误),但图像不会显示在文件夹中。
任何帮助都将不胜感激。

我认为此代码运行良好

$date=strtotime(date('Y-m-d H:i:s'));
    $pro_image_name = $date.$_FILES['your Input type File Name']['name'];
    $allowed =  array('gif','png','jpg');
    $ext = pathinfo($pro_image_name, PATHINFO_EXTENSION);
    $root_path = get_template_directory();
    if(!in_array($ext,$allowed) ) { ?>
            <span style="font-size:22px; color:red;">Uploaded File Not Supported</span>
   <?php } else {
   move_uploaded_file($_FILES['updateimg']['tmp_name'],$root_path."/images/".$pro_image_name);

        $image_get_path =  site_url()."/wp-content/themes/prathak/images/".$pro_image_name;
                 update_user_meta(get_current_user_id() , 'userpic' , $image_get_path );


    }
$date=strotime(日期('Y-m-dh:i:s');
$pro_image_name=$date.$\u文件['your Input type File name']['name'];
$allowed=array('gif'、'png'、'jpg');
$ext=pathinfo($pro\u image\u name,pathinfo\u EXTENSION);
$root_path=get_template_directory();
如果(!in_数组($ext,$allowed)){?>
不支持上载的文件

您的文件夹和服务器用户之间的权限设置是否正确?@Jaxi,我正在本地测试,所以,我想应该可以,对吧?当我尝试将它们上载到wp uploads文件夹时,它们似乎出现了。