Php 无法将文件类型发送到服务器

Php 无法将文件类型发送到服务器,php,android,image-uploading,Php,Android,Image Uploading,将图像上载到PHP服务器时,我将其作为文件发送,方式如下: entity.addPart("image_file", new FileBody(new File(file_path))); httppost.setEntity(entity); 但在服务器端,我得到一个错误: 不允许您尝试上载的文件类型 因为正在发送的数据是: [image_file] => Array ( [name] => IMG_20130801_124102.jpg

将图像上载到PHP服务器时,我将其作为文件发送,方式如下:

entity.addPart("image_file", new FileBody(new File(file_path)));
httppost.setEntity(entity);
但在服务器端,我得到一个错误:

不允许您尝试上载的文件类型

因为正在发送的数据是:

[image_file] => Array
    (
        [name] => IMG_20130801_124102.jpg
        [type] => 
        [tmp_name] => C:\wamp\tmp\php37E.tmp
        [error] => 0
        [size] => 2084727
    )
没有类型的值


据我所知,这应该是自动进行的。或者我应该将其设置在某个位置?

您可以检查以下事项:

  • 如果在PHP配置文件中将“jpg”设置为允许的类型
  • 如果您尝试上载的图像超过php.ini文件中设置的“upload\u max\u filesize”。您可以使用较小的图像进行测试,看看是否有任何更改

  • 是的,我查了1<代码>$config['allowed_types']='gif | jpg | jpeg | png'2。对于大小问题,我收到了一条不同的消息:
    上传的文件超过了PHP配置文件中允许的最大大小。
    改为尝试:entity.addPart(“image_file”、新文件体(新文件(file_路径)、“image/jpeg”);