0

我有一些代码可以将图像发布到上传到数据库的 php 脚本中,当它添加到数据库时,文件类型是 application/oct???? (这是什么)

无论如何在android阶段将其更改为jpg文件?

下面是我的代码

HttpClient client = new DefaultHttpClient();  
             String postURL = "http://10.0.2.2:90/mobileupload3.php";                
             HttpPost post = new HttpPost(postURL); 


         FileBody bin = new FileBody(file);

         MultipartEntity reqEntity = new MultipartEntity();  
         reqEntity.addPart("image", bin);
         reqEntity.addPart("name", new StringBody(enteredName));
         reqEntity.addPart("gender", new StringBody(radio));
         reqEntity.addPart("cat", new StringBody(radio2));
         reqEntity.addPart("lat", new StringBody(lat));
         reqEntity.addPart("lon", new StringBody(lon));

         post.setEntity(reqEntity);  
         HttpResponse response = client.execute(post);  
         HttpEntity resEntity = response.getEntity();  
         if (resEntity != null) {    
                   Log.i("RESPONSE",EntityUtils.toString(resEntity));
             }
    } catch (Exception e) {
        e.printStackTrace();
    }

    }
}
4

1 回答 1

0

application/oct(我假设您的意思是application/octet-stream)是通用二进制文件的MIME类型。

如果没有关于您的上传方法的更多信息,我相信您问题的另一部分已经在 SO here上得到了回答。

于 2011-02-08T21:32:40.807 回答