无法将超过700KB的文件上传到服务器

时间:2019-01-05 12:42:49

标签: php android mysql webserver

我正在尝试通过 android应用将一些文本和一些图像上传到Web服务器,当我上传的文本少于700KB的图像时,一切都是完美的,但是当图像超过700KB时,则是完美的它没有上传任何东西

我正在使用ImageZipper库压缩图像,retrofit2进行上传,并且我将图像上传为base64。

我在服务器(CPanal)上的任何地方创建了php.ini文件,并且在任何地方都无法工作,编辑了.htaccess,但它没有任何作用,然后在阅读了Godaddy支持的教程后,我编辑了.user.ini,它没有也不能正常工作,现在是最终编辑。

我将所有这些文件编辑为以下内容:

file_uploads = On
max_input_time = 1200
max_execution_time = 1200
post_max_size = 128M
max_file_uploads = 128M
upload_max_filesize = 1024M
memory_limit = 512M

当我通过phpinfo()检查php信息后,我得到了:

本地价值

file_uploads = On
post_max_size = 128M
upload_max_filesize = 1024M
max_input_time = 1200
max_file_uploads = 128M
max_execution_time = 1200
memory_limit = 512M

主值

file_uploads = On
post_max_size = 128M
upload_max_filesize = 1G
max_input_time = 600
max_file_uploads = 20
max_execution_time = 6000
memory_limit = 512M

我正在使用简单的php文件进行上传

<?php 
include "connection.php.php";

$sucess = 105;
$fail = 107;

$base = $_POST['sales_images'];
$filename = $_POST['sales_images_names'];
$tArabic = $_POST['tArabic'];
$tEnglish = $_POST['tEnglish'];
$tRussian = $_POST['tRussian'];
$tItalian = $_POST['tItalian'];
$dArabic = $_POST['dArabic'];
$dEnglish = $_POST['dEnglish'];
$dRussian = $_POST['dRussian'];
$dItalian = $_POST['dItalian'];
$lititude = $_POST['lititude'];
$longitude = $_POST['longitude'];
$egy = $_POST['egy'];
$eur = $_POST['eur'];
$rub = $_POST['rub'];
$usd = $_POST['usd'];
$bedroom = $_POST['bedroom'];
$bathroom = $_POST['bathroom'];
$size = $_POST['size'];
$arabicArea = $_POST['arabicArea'];
$englishArea = $_POST['englishArea'];
$russianArea = $_POST['russianArea'];
$italianArea = $_POST['italianArea'];
$arabicType = $_POST['arabicType'];
$englishType = $_POST['englishType'];
$russianType = $_POST['russianType'];
$italianType = $_POST['italianType'];
$ref = $_POST['ref'];
$ac = $_POST['ac'];
$pool = $_POST['pool'];
$balcony = $_POST['balcony'];
$furnished = $_POST['furnished'];
$mountain = $_POST['mountain'];
$sea = $_POST['sea'];
$animals = $_POST['animals'];
$basment = $_POST['basment'];
$roof = $_POST['roof'];
$smoking = $_POST['smoking'];
$wm = $_POST['wm'];
$internet = $_POST['internet'];
$singleBed = $_POST['singleBed'];
$doubleBed = $_POST['doubleBed'];
$groundFloor = $_POST['groundFloor'];
$b1stFloor = $_POST['1stFloor'];
$b2stFloor = $_POST['2stFloor'];
$b3stFloor = $_POST['3stFloor'];
$parking = $_POST['parking'];
$hotDeal = $_POST['hotDeal'];

$sql = "INSERT INTO `sale`(`ref`, `sqm`, `avaliable`, `bedroom`, `bathroom`, `hot_deal`) VALUES ('$ref','$size',1,'$bedroom','$bathroom',$hotDeal)";
$result = mysqli_query($con, $sql);

if ($result === TRUE) {
$last_id = $con->insert_id;
$sql2 = "INSERT INTO `sales_locations`(`sales_id`, `latitude`, `longitude`) VALUES ('$last_id','$lititude','$longitude')";
$result2 = mysqli_query($con, $sql2);
$sql3 = "INSERT INTO `sale_currency`(`sale_id`, `egp`, `usd`, `eur`, `rub`) VALUES ('$last_id','$egy','$usd','$eur','$rub')";
$result3 = mysqli_query($con, $sql3);

$sql4 = "INSERT INTO sale_facilities(sale_id, a_c, pool, balacony, parking, w_m, furnished, mountain_view, sea_view, animals, basement, roof_terrace, smoking, internet, double_bed, single_bed, ground_floor, 1st_floor, 2st_floor, 3st_floor) VALUES ('$last_id',$ac,$pool,$balcony,$parking,$wm,$furnished,$mountain,$sea,$animals,$basment,$roof,$smoking,$internet,$doubleBed,$singleBed,$groundFloor,$b1stFloor,$b2stFloor,$b3stFloor)";
$result4 = mysqli_query($con, $sql4);

$sql5 = "INSERT INTO sale_translation(sale_id, language_code, title, description, area, type) VALUES
('$last_id', 'ar','$tArabic','$dArabic','$arabicArea','$arabicType'),
('$last_id', 'en','$tEnglish','$dEnglish','$englishArea','$englishType'),
('$last_id', 'ru','$tRussian','$dRussian','$russianArea','$russianType'),
('$last_id', 'it','$tItalian','$dItalian','$italianArea','$italianType')";
$result5 = mysqli_query($con, $sql5);


$length = count($base);

for($i = 0; $i < $length; $i++) {
$imageNow = time();
$new_imageFilename = $imageNow . "_" . $filename[$i]; // use $value instead of $filename - because $filename is an array

$sql6 = "INSERT INTO `sale_image`(`sale_id`, `img_url`) VALUES ('$last_id','$new_imageFilename')";
$result6 = mysqli_query($con, $sql6);

$binary=base64_decode($base[$i]);
$file = fopen('files/sales/' . $new_imageFilename, 'wb');
fwrite($file, $binary);
fclose($file);      
}

echo "New record created successfully. Last inserted ID is: " . $last_id;
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}

$jsonResult = '{"state":';
if($result){
$jsonResult.= $sucess;
}else {
$jsonResult.= $fail;
}
$jsonResult .="}";
print_r($jsonResult);
?>

这是我的代码

private void insertSales(){

        SharedPreferences salesData = getSharedPreferences("sales", Context.MODE_PRIVATE);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ServiceConstants.URL)
                .build();

        ApiConfig apiConfig = retrofit.create(ApiConfig.class);

        Call<ResponseBody> addSales = apiConfig.uploadSales(imageData,
                fileNameList,
                salesData.getString("tArabic", null),
                salesData.getString("tEnglish", null),
                salesData.getString("tRussian", null),
                salesData.getString("tItalian",null),
                salesData.getString("dArabic", null),
                salesData.getString("dEnglish", null),
                salesData.getString("dRussian", null),
                salesData.getString("dItalian",null),
                salesData.getString("lititude", null),
                salesData.getString("longitude", null),
                salesData.getString("egy", null),
                salesData.getString("eur", null),
                salesData.getString("rub", null),
                salesData.getString("usd", null),
                salesData.getString("bedroom", null),
                salesData.getString("bathroom", null),
                salesData.getString("size", null),
                salesData.getString("arabicArea", null),
                salesData.getString("englishArea", null),
                salesData.getString("russianArea", null),
                salesData.getString("italianArea",null),
                salesData.getString("arabicType", null),
                salesData.getString("englishType", null),
                salesData.getString("russianType", null),
                salesData.getString("italianType",null),
                salesData.getString("ref", null),
                getIntent().getExtras().getBoolean("ac"),
                getIntent().getExtras().getBoolean("pool"),
                getIntent().getExtras().getBoolean("balcony"),
                getIntent().getExtras().getBoolean("furnished"),
                getIntent().getExtras().getBoolean("mountain_view"),
                getIntent().getExtras().getBoolean("sea_view"),
                getIntent().getExtras().getBoolean("animal"),
                getIntent().getExtras().getBoolean("basment"),
                getIntent().getExtras().getBoolean("roof_terrace"),
                getIntent().getExtras().getBoolean("smoking"),
                getIntent().getExtras().getBoolean("wm"),
                getIntent().getExtras().getBoolean("internet"),
                getIntent().getExtras().getBoolean("single_bed"),
                getIntent().getExtras().getBoolean("double_bed"),
                getIntent().getExtras().getBoolean("ground_floor"),
                getIntent().getExtras().getBoolean("1st_floor"),
                getIntent().getExtras().getBoolean("2st_floor"),
                getIntent().getExtras().getBoolean("3st_floor"),
                getIntent().getExtras().getBoolean("parking"),
                getIntent().getExtras().getBoolean("hot_deal"));
        addSales.enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                Toast.makeText(SalesImages.this, "success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
                Toast.makeText(SalesImages.this, "fail" + t.getMessage(), Toast.LENGTH_SHORT).show();
                t.printStackTrace();
            }
        });
}

在这里

@FormUrlEncoded
@POST("/androidfiles/insertSales.php")
Call<ResponseBody> uploadSales(@Field("sales_images[]") ArrayList<String> salesImages,
                               @Field("sales_images_names[]") ArrayList<String> salesImagesNames,
                               @Field("tArabic") String arabicTitle,
                               @Field("tEnglish") String englishTitle,
                               @Field("tRussian") String russianTitle,
                               @Field("tItalian") String italianTitle,
                               @Field("dArabic") String arabicDescription,
                               @Field("dEnglish") String englishDescription,
                               @Field("dRussian") String russianDescription,
                               @Field("dItalian") String italianDescription,
                               @Field("lititude") String lititude,
                               @Field("longitude") String longitude,
                               @Field("egy") String egy,
                               @Field("eur") String eur,
                               @Field("rub") String rus,
                               @Field("usd") String usd,
                               @Field("bedroom") String bedroom,
                               @Field("bathroom") String bathroom,
                               @Field("size") String size,
                               @Field("arabicArea") String arabicArea,
                               @Field("englishArea") String englishArea,
                               @Field("russianArea") String russianArea,
                               @Field("italianArea") String italianArea,
                               @Field("arabicType") String arabicType,
                               @Field("englishType") String englishType,
                               @Field("russianType") String russianType,
                               @Field("italianType") String italianType,
                               @Field("ref") String ref,
                               @Field("ac") Boolean ac,
                               @Field("pool") Boolean pool,
                               @Field("balcony") Boolean balcony,
                               @Field("furnished") Boolean furnished,
                               @Field("mountain") Boolean mountainView,
                               @Field("sea") Boolean seaView,
                               @Field("animals") Boolean animals,
                               @Field("basment") Boolean basment,
                               @Field("roof") Boolean roofTerrace,
                               @Field("smoking") Boolean smoking,
                               @Field("wm") Boolean wm,
                               @Field("internet") Boolean internet,
                               @Field("singleBed") Boolean singleBed,
                               @Field("doubleBed") Boolean doubleBed,
                               @Field("groundFloor") Boolean groundFloor,
                               @Field("1stFloor") Boolean s1stFloor,
                               @Field("2stFloor") Boolean s2stFloor,
                               @Field("3stFloor") Boolean s3stFloor,
                               @Field("parking") Boolean parking,
                               @Field("hotDeal") Boolean hotDeal);

请我需要帮助,我花了一个星期,仍然找不到任何提款。

0 个答案:

没有答案