您的位置:首页 > 移动开发 > Android开发

Android 上传头像(文件)到服务器

2016-09-06 16:35 423 查看
现在很多app都用到了头像的功能,我的项目中也用到了。

头像上传分几步:

1.获取头像

2.剪裁头像

3.文件上传

4.服务器的接受保存

首先第一步,无非就是两种方式

1,拍照

2,相册选择

之前的博客中有现到,不重复,链接:

http://blog.csdn.net/w18756901575/article/details/52087242

http://blog.csdn.net/w18756901575/article/details/52085157

第二步,裁剪头像

这一步我用的时鸿洋大神的
4000
东西,是个自定的控件,不过我对其中代码进行了一点点的修改,使之更适合自己的项目,里面原理就是监听onTouchEvent来对缩放,双击事件进行相应的处理,裁剪就是根据大小,创建一个新的bitmap,当然说起来挺简单,如果没有别人的代码可以借鉴参考,估计有的搞了,在此谢谢鸿洋大神,下面是鸿洋大神的博客链接:

http://blog.csdn.net/lmj623565791/article/details/39761281

裁剪图片好像还可以调用Android自带的裁剪功能,不过我没用过,

第三步,上传图片,

上传图片不过也就是上传文件,可以将文件转化为byte数组然后进行base64转码后进行上传,在服务器接收到后,将string解码成byte数组,然后在转化为文件。

当然上传的方法有很多,肯定不止这一种 ,因为项目的Android和web接口都是我写的所已我就这样写啦…谁让自己的web技术有限呢,原来写Android的时候一直说调用接口接口,原来自己写了才知道,其实就是一个配置好servlet的java文件.⊙﹏⊙||

写接口和写Android差不过嘛,都是用Java写的,本家嘛

对了文件上传的时候如果从本地读取,会需要读取sd卡的权限,我在6.0的模拟器上测试的时候,一直有问题,找了半天才发现是因为,没有申请权限,,,设立的权限不仅仅时AndroidManifest里面的权限声明,在6.0的系统中需要用代码弹出对话框向用户申请..

贴下请求代码

/**
* 请求权限
*/
public void getUserPar() {
//        Log.d("测试--授权信息", ContextCompat.checkSelfPermission(this,
//                Manifest.permission.WRITE_EXTERNAL_STORAGE) + "");
//        Log.d("测试--已授权", PackageManager.PERMISSION_GRANTED + "");
//        Log.d("测试--未授权", PackageManager.PERMISSION_DENIED + "");
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE},
1);
}
}

@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case 1: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
L.d("同意");
} else {
L.d("拒绝");
}
return;
}
}
}


还有文件和数组相互转化的代码

/**
* 将file文件转化为byte数组
*
* @param filePath
* @return
*/
public static byte[] getBytes(String filePath) {
byte[] buffer = null;
try {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
fis.close();
bos.close();
buffer = bos.toByteArray();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return buffer;
}

/**
* 将byte数组转化为file文件
*
* @param bfile
* @param filePath
* @param fileName
*/
public static void getFile(byte[] bfile, String filePath, String fileName) {
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try {
File dir = new File(filePath);
if (!dir.exists() && dir.isDirectory()) {// 判断文件目录是否存在
dir.mkdirs();
}
file = new File(filePath + "\\" + fileName);
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(bfile);
bos.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}


还有base64转码的:

http://blog.csdn.net/w18756901575/article/details/51073847

嗯,好像只有这些,,没了,,end

对了还有圆角,模糊,图片压缩,,,一起放上去吧



圆形图片效果:

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.ImageView;

import com.yesun.league.R;
import com.yesun.league.code.utils.DimensUtils;

/**
* 自定义View,实现圆角,圆形等效果
*
* @author zhy
*/
public class CustomImageView extends ImageView {

/**
* TYPE_CIRCLE / TYPE_ROUND
*/
private int type;
private static final int TYPE_CIRCLE = 0;
private static final int TYPE_ROUND = 1;

/**
* 图片
*/
private Bitmap mSrc;

/**
* 圆角的大小
*/
private int mRadius;

/**
* 控件的宽度
*/
private int mWidth;
/**
* 控件的高度
*/
private int mHeight;

public CustomImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public CustomImageView(Context context) {
this(context, null);
}

/**
* 初始化一些自定义的参数
*
* @param context
* @param attrs
* @param defStyle
*/
public CustomImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.CustomImageView, defStyle, 0);

int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case R.styleable.CustomImageView_src:
mSrc = BitmapFactory.decodeResource(getResources(),
a.getResourceId(attr, 0));
break;
case R.styleable.CustomImageView_type:
type = a.getInt(attr, 0);// 默认为Circle
break;
case R.styleable.CustomImageView_borderRadius:
mRadius = a.getDimensionPixelSize(attr, (int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f,
getResources().getDisplayMetrics()));// 默认为10DP
break;
}
}

a.recycle();
}

@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
this.mSrc = bm;
postInvalidate();
}

/**
* 计算控件的高度和宽度
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
/**
* 设置宽度
*/
int specMode = MeasureSpec.getMode(widthMeasureSpec);
int specSize = MeasureSpec.getSize(widthMeasureSpec);

if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
{
mWidth = specSize;
} else {
// 由图片决定的宽
int desireByImg = getPaddingLeft() + getPaddingRight()
+ mSrc.getWidth();
if (specMode == MeasureSpec.AT_MOST) {//wrap_content
mWidth = Math.min(desireByImg, specSize);
} else

mWidth = desireByImg;
}

/***
* 设置高度
*/

specMode = MeasureSpec.getMode(heightMeasureSpec);
specSize = MeasureSpec.getSize(heightMeasureSpec);
if (specMode == MeasureSpec.EXACTLY) {// match_parent , accurate
mHeight = specSize;
} else {
int desire = getPaddingTop() + getPaddingBottom()
+ m
1375b
Src.getHeight();

if (specMode == MeasureSpec.AT_MOST) {// wrap_content
mHeight = Math.min(desire, specSize);
} else
mHeight = desire;
}

setMeasuredDimension(mWidth, mHeight);

}

/**
* 绘制
*/
@Override
protected void onDraw(Canvas canvas) {
switch (type) {
// 如果是TYPE_CIRCLE绘制圆形
case TYPE_CIRCLE:
int min = Math.min(mWidth, mHeight);
/**
* 长度如果不一致,按小的值进行压缩
*/
mSrc = Bitmap.createScaledBitmap(mSrc, min, min, false);
canvas.drawBitmap(createCircleImage(mSrc, min), 0, 0, null);

//下面是绘制圆环的,不喜欢的可以不要
Paint paint=new Paint();
int centre = getWidth()/2; //获取圆心的x坐标
int radius = (int) (centre - DimensUtils.dp2px(getContext(),3)/2); //圆环的半径
paint.setColor(0x88ffffff); //设置圆环的颜色
paint.setStyle(Paint.Style.STROKE); //设置空心
paint.setStrokeWidth(DimensUtils.dp2px(getContext(),3)); //设置圆环的宽度
paint.setAntiAlias(true);  //消除锯齿
canvas.drawCircle(centre, centre, radius, paint); //画出圆环
break;
case TYPE_ROUND:

mSrc = Bitmap.createScaledBitmap(mSrc, mWidth, mHeight, false);
canvas.drawBitmap(createRoundConerImage(mSrc), 0, 0, null);
break;
}

}

/**
* 根据原图和变长绘制圆形图片
*
* @param source
* @param min
* @return
*/
private Bitmap createCircleImage(Bitmap source, int min) {
final Paint paint = new Paint();
paint.setAntiAlias(true);
Bitmap target = Bitmap.createBitmap(min, min, Config.ARGB_8888);
/**
* 产生一个同样大小的画布
*/
Canvas canvas = new Canvas(target);

/**
* 首先绘制圆形
*/
canvas.drawCircle(min / 2, min / 2, min / 2, paint);
/**
* 使用SRC_IN,参考上面的说明
*/
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));//相交部分取后绘制上去的
//        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));//相交部分取
/**
* 绘制图片
*/
canvas.drawBitmap(source, 0, 0, paint);
return target;
}

/**
* 根据原图添加圆角
*
* @param source
* @return
*/
private Bitmap createRoundConerImage(Bitmap source) {
final Paint paint = new Paint();
paint.setAntiAlias(true);
Bitmap target = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
Canvas canvas = new Canvas(target);
RectF rect = new RectF(0, 0, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rect, mRadius, mRadius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(source, 0, 0, paint);
return target;
}
}


压缩,模糊都在这个工具类中,自己看吧:

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;

/**
* Created by wkk on 2016/8/23.
* <p>
* 工具类
*/
public class BitmapUtils {

//   compile 'com.yolanda.nohttp:nohttp:1.0.4'

/**
* 从本地读取图片
*
* @param path
* @return
*/
public static Bitmap getBitmapForPath(String path) {
try {
FileInputStream in = new FileInputStream(path);
Bitmap bitmap = BitmapFactory.decodeStream(in);
in.close();
return bitmap;
} catch (Exception e) {
}
return null;
}

/**
* 获取资源文件中的图片
*
* @param context
* @param resourcesId
* @return
*/
public static Drawable getDrawableFormResources(Context context, int resourcesId) {
Resources resources = context.getResources();
return new BitmapDrawable(resources, BitmapFactory.decodeResource(resources, resourcesId));
}

/**
* 从资源文件中获取bitmap对象
*
* @param context
* @param resourcesId
* @return
*/
public static Bitmap getBitmapFromResources(Context context, int resourcesId) {
return BitmapFactory.decodeResource(context.getResources(), resourcesId);
}

/**
* bitmap转byte数组
*
* @param bitmap
* @return
*/
public static byte[] getBitmapbyte(Bitmap bitmap) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] datas = baos.toByteArray();
try {
baos.flush();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
return datas;
}

/**
* byte转bitmap数组
*
* @param b
* @return
*/
public static Bitmap getBitmaoFrombyte(byte[] b) {
return BitmapFactory.decodeByteArray(b, 0, b.length);
}

/**
* 压缩1
*
* @param srcPath
* @return
*/
public static Bitmap getimage(String srcPath) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts);//此时返回bm为空

newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
float hh = 800f;//这里设置高度为800f
float ww = 480f;//这里设置宽度为480f
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
return compressImage(bitmap);//压缩好比例大小后再进行质量压缩
}

/**
* 压缩2
*
* @param image
* @return
*/
public static Bitmap comp(Bitmap image) {

ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
if (baos.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
baos.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, 50, baos);//这里压缩50%,把压缩后的数据存放到baos中
}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
float hh = 800f;//这里设置高度为800f
float ww = 480f;//这里设置宽度为480f
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;//设置缩放比例
newOpts.inPreferredConfig = Bitmap.Config.RGB_565;//降低图片从ARGB888到RGB565
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
isBm = new ByteArrayInputStream(baos.toByteArray());
bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
return compressImage(bitmap);//压缩好比例大小后再进行质量压缩
}

/**
* 质量压缩
*
* @param image
* @return
*/
public static Bitmap compressImage(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
int options = 100;
while (baos.toByteArray().length / 1024 > 100) {    //循环判断如果压缩后图片是否大于100kb,大于继续压缩
baos.reset();//重置baos即清空baos
options -= 10;//每次都减少10
image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中

}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片
return bitmap;
}

/**
* 获取图片大小
*
* @param bitmap
* @return
*/
public static long getBitmapsize(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
return bitmap.getByteCount();
}
return bitmap.getRowBytes() * bitmap.getHeight();
}

/**
* 对图片进行模糊处理
*
* @param bitmap
* @param context
* @return
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap blurBitmap(Bitmap bitmap, Context context) {
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
RenderScript rs = RenderScript.create(context.getApplicationContext());
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
blurScript.setRadius(25f);
blurScript.setInput(allIn);
blurScript.forEach(allOut);
allOut.copyTo(outBitmap);
bitmap.recycle();
rs.destroy();
return outBitmap;
}

public static Bitmap drawableToBitmap(Drawable drawable) {
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
//canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}

/**
* 水平方向模糊度
*/
private static float hRadius = 10;
/**
* 竖直方向模糊度
*/
private static float vRadius = 10;
/**
* 模糊迭代度
*/
private static int iterations = 7;
private static float a = 1.3f;

/**
* 模糊图片
* @param bmp
* @return
*/
public static Drawable BoxBlurFilter(Bitmap bmp) {
hRadius = hRadius * a;
vRadius = vRadius * a;
iterations = (int) (iterations * a);

int width = bmp.getWidth();
int height = bmp.getHeight();
int[] inPixels = new int[width * height];
int[] outPixels = new int[width * height];
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bmp.getPixels(inPixels, 0, width, 0, 0, width, height);
for (int i = 0; i < iterations; i++) {
blur(inPixels,
outPixels, width, height, hRadius);
blur(outPixels,
inPixels, height, width, vRadius);
}
blurFractional(inPixels,
outPixels, width, height, hRadius);
blurFractional(outPixels,
inPixels, height, width, vRadius);
bitmap.setPixels(inPixels,
0,
width, 0,
0,
width, height);
Drawable drawable = new BitmapDrawable(bitmap);
return drawable;
}

public static void blur(int[] in, int[] out, int width, int height, float radius) {
int widthMinus1 = width - 1;
int r = (int) radius;
int tableSize = 2 * r + 1;
int divide[] = new int[256 * tableSize];
for (int i = 0; i < 256 * tableSize; i++)
divide[i] = i / tableSize;
int inIndex = 0;
for (int y = 0; y < height; y++) {
int outIndex = y;
int ta = 0, tr = 0, tg = 0, tb = 0;
for (int i = -r; i <= r; i++) {
int rgb = in[inIndex + clamp(i, 0, width - 1)];
ta += (rgb >> 24) & 0xff;
tr += (rgb >> 16) & 0xff;
tg += (rgb >> 8) & 0xff;
tb += rgb & 0xff;
}
for (int x = 0; x < width; x++) {
out[outIndex] = (divide[ta] << 24) | (divide<< 16) | (divide[tg] << 8)
| divide[tb];
int i1 = x + r + 1;
if (i1 > widthMinus1)
i1 = widthMinus1;
int i2 = x - r;
if (i2 < 0)
i2 = 0;
int rgb1 = in[inIndex + i1];
int rgb2 = in[inIndex + i2];
ta += ((rgb1 >> 24) & 0xff) - ((rgb2 >> 24) & 0xff);
tr += ((rgb1 & 0xff0000) - (rgb2 & 0xff0000)) >> 16;
tg += ((rgb1 & 0xff00) - (rgb2 & 0xff00)) >> 8;
tb += (rgb1 & 0xff) - (rgb2 & 0xff);
outIndex += height;
}
inIndex += width;
}
}

public static void blurFractional(int[] in, int[] out, int width, int height, float radius) {
radius -= (int) radius;
float f = 1.0f / (1 + 2 * radius);
int inIndex = 0;
for (int y = 0; y < height; y++) {
int outIndex = y;
out[outIndex] = in[0];
outIndex += height;
for (int x = 1; x < width - 1; x++) {
int i = inIndex + x;
int rgb1 = in[i - 1];
int rgb2 = in[i];
int rgb3 = in[i + 1];
int a1 = (rgb1 >> 24)
& 0xff;
int r1
= (rgb1 >> 16)
& 0xff;
int g1
= (rgb1 >> 8)
& 0xff;
int b1
= rgb1 & 0xff;
int a2
= (rgb2 >> 24)
& 0xff;
int r2
= (rgb2 >> 16)
& 0xff;
int g2
= (rgb2 >> 8)
& 0xff;
int b2
= rgb2 & 0xff;
int a3
= (rgb3 >> 24)
& 0xff;
int r3
= (rgb3 >> 16)
& 0xff;
int g3
= (rgb3 >> 8)
& 0xff;
int b3
= rgb3 & 0xff;
a1
= a2 + (int)
((a1 + a3) * radius);
r1
= r2 + (int)
((r1 + r3) * radius);
g1
= g2 + (int)
((g1 + g3) * radius);
b1
= b2 + (int)
((b1 + b3) * radius);
a1
*= f;
r1
*= f;
g1
*= f;
b1
*= f;
out[outIndex]
= (a1 << 24)
| (r1 << 16)
| (g1 << 8)
| b1;
outIndex
+= height;
}
out[outIndex]
= in[width - 1];
inIndex
+= width;
}
}

public static int clamp(int x,
int a,
int b) {
return (x
< a) ? a : (x > b) ? b : x;
}

}


嗯哼,,真的没了,,end

2017/10/12 08:49

关于上传文件到服务器的.两种思路或者是方法.

1.将文件转成base64编码放在字段里面,像正常的http交互一样去访问服务器上传

2.将文件写入流中上传
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: