现在localhost可以访问了。
@H_
301_0@同样
PHPMyadmin在localhost下不能正常访问在127.0.0.1能正常访问,
解决方法:
点击根目录下的alias目录,打开
PHPmyadmin.conf
配置文件,和上面
修改http.conf一样把
修改为
Allow from all
@H_
301_0@3. 再此输入 : http://本机IP地址 回车
显示页面 OK! 至于为什么要第二步、第三步呢,我就不说了。。。留给新人去想想吧! 大神直接无视。。。。。
4.写一个
上传图片的
PHP文件,当然我一个敲java的孩子一下子怎么可能憋的出来,那怎么办,当然是
百度参考别人的了,下面的
PHP代码源自网络,亲测没有
错误:
PHP;">
[
PHP] view plaincopyprint?
true,"msg" => $_FILES ['attach'] ['name']
);
echo json_encode ( $array );
} else {
$array = array (
"status" => false,"msg" => "There was an error uploading the file,please try again!" . $_FILES ['attach'] ['error']
);
echo json_encode ( $array );
}
?>
@H_
301_0@5.将上面的
PHP文件放在WM安装目录下的www目录下,我的如下图所示,仅供参考:

@H_
301_0@6.经过上面几个步骤,
PHP端已经搭建好了,现在就是回到android端改改IP地址测试下就oK了,
代码段如下:
PHP;">
[java] view plaincopyprint?
//HTTP
上传图片
RequestParams params = new RequestParams();
try {
//将压缩后的bitmap保存为
图片文件
String saveImgPath=getSD_Path()+"/saveimg.png";
File saveimg=new File(saveImgPath);
FileOutputStream fos = new FileOutputStream(saveimg);
bmp.compress(Bitmap.CompressFormat.PNG,100,fos);
fos.flush();
fos.close();
//
上传压缩后的
文件,大约100k左右
File uploadImg=new File(saveImgPath);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//上传地址
String url=URLconfigs.UploadHeadImage_ukey+myprefs.Ukey().get();
PHP";
LogUtil.e(TAG,"upload img url :"+url);
AsyncHttpUtil.post_loading(context,url,params,new MyTextHttpResponseHandler() {
@Override
public void onSuccess(int status,Header[] arg1,String json) {
super.onSuccess(status,arg1,json);
LogUtil.e(TAG,"上传图片 json :"+json);
RespondBaseEntity entity=GsonUtil.GetFromJson(json,RespondBaseEntity.class);
if(entity.isStatus()){
//上传成功,设置图片
face.setImageBitmap(bmp);
ToastUtils.show(context,"上传成功");
}else{
ToastUtils.show(context,json);
}
myprefs.position().put(0);
}
@Override
public void onFailure(int arg0,String arg2,Throwable arg3) {
super.onFailure(arg0,arg2,arg3);
myprefs.position().put(0);
arg3.printStackTrace();
ToastUtils.show(context,R.string.network_unavailable);
}
@H_
301_0@params.put("attach",uploadImg); 这里的attach参数是和服务端一一对应的,别乱改。。。。
String url="
PHP">http://192.168.0.8/upload.
PHP"; 这个192.168.0.8是我的
PHP部署的地址,改成你自己的就行了。
@H_
301_0@
PS:别犯2,用了127.0.0.1 想想为啥不能用127.0.0.1
@H_
301_0@到此就是building,runing了。 发现OK。。。。 可以
上传,并在www目录下找到upload目录,upload目录下有
上传的
图片。。。。

@H_
301_0@
7.这就纳闷了。。。。 我又鼓起勇气找了
PHP后端,跟他激烈的讨论一番后,发现是服务器坑了爹啊! 800块一年的服务器。。。。。唉。。。不说了。。。。