我有一个 Android应用程序,它将图像发送到我的数据库;

public class NewProductActivity extends Activity {

// Progress Dialog

private ProgressDialog pDialog;

public String image_str;

JSONParser jsonParser = new JSONParser();

EditText inputName;

EditText inputPrice;

EditText inputDesc;

EditText inputImg;

Button btnTakePhoto;

ImageView imgTakenPhoto;

private static final int CAM_REQUREST = 1313;

// url to create new product

private static String url_create_product = "http://buiud.com/android_connect/create_product.php";

// JSON Node names

private static final String TAG_SUCCESS = "success";

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.add_product);

// Edit Text

inputName = (EditText) findViewById(R.id.inputName);

inputPrice = (EditText) findViewById(R.id.inputPrice);

inputDesc = (EditText) findViewById(R.id.inputDesc);

//inputImg = (EditText) findViewById(R.id.imageView1);

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);

ByteArrayOutputStream stream = new ByteArrayOutputStream();

bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want.

byte[] byte_arr = stream.toByteArray();

image_str = Base64.encodeToString(byte_arr, Base64.DEFAULT);

// Create button

Button btnCreateProduct = (Button) findViewById(R.id.btnCreateProduct);

// button click event

btnCreateProduct.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

// creating new product in background thread

new CreateNewProduct().execute();

}

});

btnTakePhoto = (Button) findViewById(R.id.button1);

imgTakenPhoto = (ImageView) findViewById(R.id.imageView1);

btnTakePhoto.setOnClickListener(new btnTakePhotoClicker());

}

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

// TODO Auto-generated method stub

super.onActivityResult(requestCode, resultCode, data);

if (requestCode == CAM_REQUREST) {

Bitmap thumbnail = (Bitmap) data.getExtras().get("data");

imgTakenPhoto.setImageBitmap(thumbnail);

}

}

class btnTakePhotoClicker implements Button.OnClickListener

{

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

startActivityForResult(cameraIntent, CAM_REQUREST);

}

}

/**

* Background Async Task to Create new product

* */

class CreateNewProduct extends AsyncTask {

/**

* Before starting background thread Show Progress Dialog

* */

@Override

protected void onPreExecute() {

super.onPreExecute();

pDialog = new ProgressDialog(NewProductActivity.this);

pDialog.setMessage("Creating Product..");

pDialog.setIndeterminate(false);

pDialog.setCancelable(true);

pDialog.show();

}

/**

* Creating product

* */

protected String doInBackground(String... args) {

String name = inputName.getText().toString();

String price = inputPrice.getText().toString();

String description = inputDesc.getText().toString();

//String image_str = inputImg.getText().toString();

// Building Parameters

List params = new ArrayList();

params.add(new BasicNameValuePair("name", name));

params.add(new BasicNameValuePair("price", price));

params.add(new BasicNameValuePair("description", description));

params.add(new BasicNameValuePair("img",image_str));

//params.add(new BasicNameValuePair("image", image));

// getting JSON Object

// Note that create product url accepts POST method

JSONObject json = jsonParser.makeHttpRequest(url_create_product,

"POST", params);

// check log cat fro response

Log.d("Create Response", json.toString());

// check for success tag

try {

int success = json.getInt(TAG_SUCCESS);

if (success == 1) {

// successfully created product

Intent i = new Intent(getApplicationContext(), AllProductsActivity.class);

startActivity(i);

// closing this screen

finish();

} else {

// failed to create product

}

} catch (JSONException e) {

e.printStackTrace();

}

return null;

}

/**

* After completing background task Dismiss the progress dialog

* **/

protected void onPostExecute(String file_url) {

// dismiss the dialog once done

pDialog.dismiss();

}

}

}

即使我想我的图像是.png它在数据库中显示为.bin,我怎么能改变它,我已经阅读过当应用程序调用create.php而不是雪茄时输入内容.我甚至无法将.bin显示为HTML页面上的图像.

php安卓传输图片到mysql_php – Android应用程序将图像发送到MySQL相关推荐

  1. ios php mysql实例_php – 从iOS应用程序将图像存储到MYSQL数据库中

    我正在使用MYSQL数据库从我的iOS应用程序中存储图像.我使用base64encoding和解码技术来存储图像. 问题: 它将名称存储在数据库中作为字符串即可.但它不是将图像存储在htdocs文件夹 ...

  2. android关键应用程序,安卓开发:Android应用程序的四个关键点

    核心提示:本教程为大家介绍在安卓开发中我们应该关注那几点. 对于一个Android应用程序来说,是由四种关键构造块组织而成的,这四种构造块分别是:Activity.Intent Receiver.Se ...

  3. Android安卓的家教平台设计小程序app毕业设计

    Android安卓的家教平台设计小程序app毕业设计

  4. Android应用程序开发——安卓应用开发介绍

    这是网易公开课 密西西比河谷州立大学:Android应用程序开发 的笔记. 视频地址:http://v.163.com/special/opencourse/developingandroidappl ...

  5. 安卓虚拟linux系统教程,在Linux上模拟Android应用程序的3种方法 | MOS86

    如果您是Android的忠实拥护者,那么您可能已经知道自己最喜欢的移动操作系统是Linux. 过去我们已经介绍了Android如何基于开放源代码组件,Android真的是开放源代码吗? Android ...

  6. 安卓应用程序一般采用什么计算机语言开发,Kotlin 编程语言成为其 Android 应用程序开发人员的首选语言...

    本年5月,谷歌在I/O大会上宣告,Kotlin编程言语成为其Android使用程序开发人员的首选言语. Kotlin是一种面向现代多平台使用程序的编程言语,成为谷歌开发Android使用程序的首选言语 ...

  7. 安卓手机python开发环境_使用Python开发Android应用程序:第一节 在手机上配置Python运行环境...

    本节目录: 1.下载和安装 Scripting Layer for Android (SL4A) 2.下载和安装 Python for android 3.第一个HelloWorld程序 1.下载和安 ...

  8. android 删除系统服务,安卓系统精简列表:精简安卓系统不可删除的应用程序汇总...

    安卓系统不可删除的应用程序列表如下: Bluetooth.apk(蓝牙:近距离文件传输工具.很少用这玩意,或压根就不知道这是啥玩意的可以删掉) Camera.apk(不能删 必须得有:系统相机 录像程 ...

  9. 基于深度学习的安卓恶意应用检测----------android manfest.xml + run time opcode, use 深度置信网络(DBN)...

    基于深度学习的安卓恶意应用检测 from:http://www.xml-data.org/JSJYY/2017-6-1650.htm 苏志达, 祝跃飞, 刘龙     摘要: 针对传统安卓恶意程序检测 ...

最新文章

  1. ssm read time out的原因_有高血压的人,认清这4点,很多高血压一直降不下来,原因在这里...
  2. jQuery 第二章
  3. WIN7无法记住远程登录密码
  4. JQuery-学习笔记02【基础——JQuery选择器】
  5. Nginx安装环境配置
  6. 011-git-将tag推送到远端
  7. 在 eclipse 中 设置 jvm 的 运行时目录
  8. java标签居住对齐_java期末复习(八)
  9. 《ArcGIS Runtime SDK for Android开发笔记》——(3)、ArcGIS Runtime SDK概述
  10. ~~欧几里得算法(附模板题)
  11. Android Broadcast Receiver 与Activity() (android 开发的四大组件)
  12. linux设置gmt时区,关于GMT UTC CST和Linux时区设置
  13. Hyper-v 2.0
  14. 新概念英语2电子版_新概念英语读100遍,英语能超神
  15. 第一章 路径规划算法概述
  16. matlab的电子线路仿真,高频电子线路Matlab仿真实验
  17. Oracle执行计划
  18. 三色球问题python_零基础入门学习Python习题3【输密码+水仙花数+摸三色球】
  19. 车载网络: CAN (Control Area Network) 控制器局域网络
  20. cmd命令和终端怎么实现切换目录

热门文章

  1. 微软资深算法工程师为AI初学者量身打造的机器学习入门书上市啦!
  2. 一个简单express+jade+mysql+bootstrap+nodejs的demo
  3. redis在PHP中的基本使用案例
  4. vi profile
  5. Node.js连接MySQL
  6. 分布式团队面临的五大问题及解决办法
  7. Linux运维人员成长之路学习书籍推荐
  8. Kipmi0 占用100% CPU1核
  9. java 为什么需要常量池
  10. python windows错误码