通过HTTP上传图片时,我得到以下数组。如何按图像的大小按降序对它们进行排序,以便最大尺寸的图像上传第一个和最小的尺寸?
Array
(
"name" => Array
(
[0] => 1.jpg
[1] => 2.jpg
[2] => 3.jpg
)
["type"] => Array
(
[0] => image/jpeg
[1] => image/jpeg
[2] => image/jpeg
)
["tmp_name"] => Array
(
[0] => e7d31fc0
[1] => qsdf0sdf
[2] => s0sdfsfs
)
["error"] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
["size"] => Array
(
[0] => 20000
[1] => 30000
[2] => 40000
)
)
因此,输出应如下:
Array
(
"name" => Array
(
[0] => 3.jpg
[1] => 2.jpg
[2] => 1.jpg
)
["type"] => Array
(
[0] => image/jpeg
[1] => image/jpeg
[2] => image/jpeg
)
["tmp_name"] => Array
(
[0] => s0sdfsfs
[1] => qsdf0sdf
[2] => e7d31fc0
)
["error"] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
["size"] => Array
(
[0] => 40000
[1] => 30000
[2] => 20000
)
)
答案 0 :(得分:1)
我想,你将在foreach循环中处理这些文件。
下面的代码怎么样?
//get files in array
$files = $_FILES['formFieldName'];
$sizes = $files['size'];
arsort($sizes); //sort in descending order but will preserve the keys
foreach ($sizes as $key => $size) {
$fileName = $files['name'][$key];
$fileSize = $size;
$fileType = $files['type'][$key];
$fileTmpName = $files['tmp_name'][$key];
$fileError = $files['error'][$key];
}
答案 1 :(得分:0)
根据Selim Mahmud的回答,我解决了这个问题:
-webkit-input-placeholder {
color: white;
}
-moz-placeholder { /* Firefox 18- */
color: white;
}
-moz-placeholder { /* Firefox 19+ */
color: white;
}
-ms-input-placeholder {
color: white;
}