Php 使用截击将图像上载到服务器

Php 使用截击将图像上载到服务器,php,android,android-volley,Php,Android,Android Volley,我有一个php代码的问题…任何人都可以改变我的php代码上传图像和更新所有数据时,用户更新他们的个人资料。我有一个保存按钮来更新所有数据 public function profileUpdate($fname, $lname, $email, $mobile, $uid, $profile_pic){ $result = mysqli_query($this->con, "SELECT * FROM users WHERE unique_id = '$uid'")

我有一个php代码的问题…任何人都可以改变我的php代码上传图像和更新所有数据时,用户更新他们的个人资料。我有一个保存按钮来更新所有数据

public function profileUpdate($fname, $lname, $email, $mobile,  $uid, $profile_pic){
    $result = mysqli_query($this->con, "SELECT * FROM users WHERE unique_id = '$uid'") 
                                                    or die(mysqli_error($this->con));       

    $no_of_rows = mysqli_num_rows($result);
    if ($no_of_rows > 0) {
        $result = mysqli_fetch_array($result);
        $old_email = $result['email'];
        $status = 0;
        $otp = rand(100000, 999999); // otp code
        if ($old_email == $email) {
            $result1 = mysqli_query($this->con, "UPDATE `users` SET `firstname` = '$fname', `lastname` = '$lname', `mobile` = '$mobile', `profile_pic` = '$profile_pic' 
                      WHERE `unique_id` = '$uid'") or die(mysqli_error($this->con));

            return $result1;
        } else {
            $result1 = mysqli_query($this->con, "UPDATE `users` SET `firstname` = '$fname',`lastname` = '$lname', `email` = '$email', `mobile` = '$mobile', `profile_pic` = '$profile_pic', `otp` = '$otp', `verified` = '$status'  
                      WHERE `unique_id` = '$uid'") or die(mysqli_error($this->con));

            return $result1;
        }


    } else {
        // user not found
        return false;
    }       

}
android片段中的图像选择器

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
保存按钮代码

String fname = eFirstName.getEditText().getText().toString();
String lname = eLastName.getEditText().getText().toString();
String email = eEmail.getEditText().getText().toString();
String mobile = eMobile.getEditText().getText().toString();
String uid = user.get("uid");
String profile_pic = getStringImage(bitmap);

profileUpdate(fname,lname,email,mobile,aclass,school,uid,profile_pic);    
onActivityResults代码

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PICK_IMAGE_REQUEST && resultCode == getActivity().RESULT_OK && data != null && data.getData() != null) {

        filePath = data.getData();
        try {
            bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), filePath);
            eProfilePic.setImageBitmap(bitmap);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

public String getStringImage(Bitmap bmp){
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] imageBytes = baos.toByteArray();
    String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
    return encodedImage;
}
截击请求码

private void ProfilePic(final String fname, final String lname, final String email, final String mobile, final String uid, final String profile_pic) {
       ..............................................
  ..........................................................

        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<String, String>();
            params.put("tag", "profile_update");
            params.put("fname", fname);
            params.put("lname", lname);
            params.put("email", email);
            params.put("mobile", mobile);              
            params.put("uid", uid);
            params.put("profile_pic", profile_pic);

            return params;
        }
private void ProfilePic(最终字符串fname、最终字符串lname、最终字符串email、最终字符串mobile、最终字符串uid、最终字符串profile_pic){
..............................................
..........................................................
@凌驾
受保护的映射getParams(){
//将参数发布到登录url
Map params=新的HashMap();
参数put(“标记”、“配置文件更新”);
参数put(“fname”,fname);
参数put(“lname”,lname);
参数put(“电子邮件”,电子邮件);
参数put(“移动”,移动);
参数put(“uid”,uid);
参数put(“profile_pic”,profile_pic);
返回参数;
}

奇怪。我没有看到用于发布图像的截图代码。也没有看到用于接收图像的php代码。所有代码都已经在这里了……我需要php方面的帮助……我正在将图像发送到base64string。现在我想转换图像字符串,并将其保存到mysql数据库中的服务器目录和文件url。没有发送图像的代码。也没有可用于发送图像的php代码接收用于从gallery获取图像的image.image picker,然后在imageview中设置On ActivityResults代码。字符串profile_pic=getStringImage(位图);正在获取图像字符串和参数。put(“profile_pic”,profile_pic);正在发送图像字符串…我想使用文件内容($path,base64_decode($profile_pic));这段代码用于在服务器中保存图像,其中$path是$path=“uploads/$uid.png”;但我不知道如何将这段代码放在php中。所以请更改我的php代码…
params.put(“profile_pic”,profile_pic);正在发送图像字符串。
。胡说八道。这只是将一些内容放入参数中。不涉及发送。发送它的代码丢失。奇怪。我没有看到用于发布图像的截取代码。也没有看到用于接收图像的php代码。所有代码都已在此处…我需要php帮助…我正在将图像发送到base64string。现在我想转换我的图像字符串并保存到mysql数据库中的服务器目录和文件url。没有发送图像的代码。也没有接收图像的php代码。图像选择器用于从gallery获取图像,然后onActivityResults代码在imageview中设置为位图。字符串配置文件\u pic=getStringImage(位图);正在获取图像字符串和参数(“profile_pic”,profile_pic);正在发送图像字符串…我想使用file_put_contents($path,base64_decode($profile_pic));这段代码将图像保存在服务器中,其中$path是$path=“uploads/$uid.png”;但我不知道如何将这段代码放在php中。所以请更改我的php代码…
params.put(“profile_pic”,profile_pic);正在发送图像字符串。
。胡说八道。这只是将一些内容放在参数中。不涉及发送。发送它的代码丢失。