wp_handle_upload - “文件为空”错误

时间:2017-05-05 16:36:47

标签: php wordpress email xampp

使用XAMPP开发Wordpress网站,这是我写的价格匹配形式。用户需要能够上传图像。这是代码的上传部分(验证后)

输出错误:“文件为空。请上传更实质的内容。此错误也可能是由于您的php.ini中禁用了上传或者post_max_size被定义为小于php中的upload_max_filesize的.ini“。

从functions.php上传代码

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

$uploadedfile = $_FILES["fileToUpload"];

$upload_overrides = array(
    'test_form' => false
);

$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );

if ( $movefile && ! isset( $movefile['error'] ) ) {
//echo __( 'File is valid, and was successfully uploaded.', 'textdomain' ) . "\n";
var_dump( $movefile );
} else {
/*
* Error generated by _wp_handle_upload()
* @see _wp_handle_upload() in wp-admin/includes/file.php
*/
$fileErr = $movefile['error'];
}
  • 我的wp-content文件夹权限设置为755
  • 我已经运行了phpinfo()以确保我链接到 对php.ini文件。

在我的php.ini文件中:

  • file_uploads =上
  • memory_limit的= 128M
  • upload_max_file_size = 25M
  • 的post_max_size = 25M

我知道这个问题已被一群人提出,并且相信我,我一直在查看所有回复并尝试一切。

有什么想法吗?

0 个答案:

没有答案
相关问题