从Android应用错误获取多张图片

时间:2019-03-25 11:58:09

标签: php image api

我正在尝试从android应用获取多张图片,但是问题是,当从app获取到5张图片时,app向我发送了一些图片为null时,其他图片也为null。但是如果所有图片都是发送到服务器已成功上传。问题是某些图像为空,因此无法将其上传到数据库中。这是我的代码

我尝试了以下代码

If(isset($_FILES['image1']) && $_FILES['image1']['error'] == 0)
                {

                    $path = APPPATH."../uploads/classified/posts/1image".$id;

                    $temp = explode(".",$_FILES['image1']['name']);

                    $extension = end($temp);

                    $fileupload = move_uploaded_file($_FILES['image1']['tmp_name'],$path.".".$extension);

                    $image1 = "1image".$id.".".$extension;

                    $flag = $this->Custom_model->update_query("1classified_post",array("image1"=>$image1), array("classified_id"=>$id));                                      

                }
If(isset($_FILES['image2']) && $_FILES['image2']['error'] == 0)
                {

                    $path = APPPATH."../uploads/classified/posts/2image".$id;

                    $temp = explode(".",$_FILES['image2']['name']);

                    $extension = end($temp);

                    $fileupload = move_uploaded_file($_FILES['image2']['tmp_name'],$path.".".$extension);

                    $image3 = "2image".$id.".".$extension;

                    $flag = $this->Custom_model->update_query("1classified_post",array("image2"=>$image2), array("classified_id"=>$id));                                      

                }
 If(isset($_FILES['image3']) && $_FILES['image3']['error'] == 0)
                {

                    $path = APPPATH."../uploads/classified/posts/3image".$id;

                    $temp = explode(".",$_FILES['image3']['name']);

                    $extension = end($temp);

                    $fileupload = move_uploaded_file($_FILES['image3']['tmp_name'],$path.".".$extension);

                    $image3 = "3image".$id.".".$extension;

                    $flag = $this->Custom_model->update_query("1classified_post",array("image3"=>$image3), array("classified_id"=>$id));                                      

                }

0 个答案:

没有答案