我的 PHP 5.6.3 版本并在 PHP.INI 中检查我的 php 支持并接受 WEBP 图像文件
它不断地给出错误。
注意:使用未定义的常量 IMAGETYPE_WEBP - 在第 19 行的 C:\xampp\htdocs\dubai\xfiles1.php 中假定为“IMAGETYPE_WEBP”
警告:image_type_to_mime_type() 期望参数 1 很长,字符串在 C:\xampp\htdocs\dubai\xfiles1.php 第 19 行中给出
我的 php 支持并接受 WEBP 文件,甚至显示 WEBP 图像。
<?php
if (isset($_POST["csubmit"])) {
$_POST["property_title"] = str_replace(' ','-','meraki developers dubai Arjan 2bhk apartment');
$_POST["property_type"] = '2bhk';
// image mime to be checked against
$imagetype = array(image_type_to_mime_type(IMAGETYPE_GIF), image_type_to_mime_type(IMAGETYPE_JPEG),
image_type_to_mime_type(IMAGETYPE_PNG),image_type_to_mime_type(IMAGETYPE_WEBP));
$error_msg = "";
$imageUploadERROR = FALSE;
$FOLDER = "uploads/";
$myfile = $_FILES["property_images"];
for ($i = 0; $i < count($myfile["name"]); $i++) {
if ($myfile["name"][$i] <> "" && $myfile["error"][$i] == 0) {
// uploaded file is OK
if (in_array($myfile["type"][$i], $imagetype)) {
// get the extention of the file
$file_extention = @strtolower(@end(@explode(".", $myfile["name"][$i])));
// Setting an unique name for the file
$file_name = $_POST["property_title"] . '-' . date("Ymd") . '_' . rand(10000, 990000) . '.' . $file_extention;
if (move_uploaded_file($myfile["tmp_name"][$i], $FOLDER . $file_name) === FALSE) {
$error_msg = "Error while uploading the file";
} else {
$error_msg = "File uploaded successfully with name: " . $file_name;
$location = 'uploads/' . $file_name;
mysqli_query($con,"insert into photo (location) values ('$location')");
}
} else {
$error_msg = "File is not a valid image type.";
}
}
if ($imageUploadERROR) {
// if upload error break the loop and display the error
break;
}
}
if ($imageUploadERROR === FALSE) {
// Failed to upload file, you can write your code here
echo $error_msg;
} else {
// file is uploaded, you can write your code here
echo "All file is uploaded successfully";
}
}?>
我不知道如何通过这个 WEBP 图像类型。
任何帮助表示赞赏
从手册...
IMAGETYPE_WEBP(整数)
image_type_to_mime_type() 和 image_type_to_extension() 函数使用的图像类型常量。(自 PHP 7.1.0 起可用)
所以这只是 -从 PHP 7.1.0 开始可用
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句