gpt4 book ai didi

PHP上传的图像被截断

转载 作者:行者123 更新时间:2023-12-04 05:10:51 25 4
gpt4 key购买 nike

我有一个上传小于 500kb 图像的表单
我遇到的问题是服务器上上传的图像部分可见/缺少图像的一部分。

有谁知道可能是什么问题?

if(isset($_POST['Submit']))
{
$image = $_FILES['image']['name']; //reads the name of the file the user submitted for uploading
if ($image) //if it is not empty
{
$filename = stripslashes($_FILES['image']['name']); //get the original name of the file from the clients machine
$extension = getExtension($filename);//get the extension of the file in a lower case format
$extension = strtolower($extension);

if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
echo '<h1>Error, allowed only: .jpg, .png, .gif</h1>';
$errors=1;
}else{
$size = filesize($_FILES['image']['tmp_name']);

if ($size > 512000){
echo '<h1 style="color:red;">Too big (Max: 500KB). Try again. </h1>';
$errors=1;
}else{ //MAX SIZE IS SMALLER

$s = $_POST['first_name'];
$ts = array("/ä/","/Ä/");
$tn = array("a","A");



$image_name= preg_replace($ts,$tn, str_replace(' ','+',$s)).'_'.time().'.'.$extension; // $image_name=time().'.'.$extension;
$newname="img/uploads/images/".$image_name;

$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied)
{
echo '<h1>Could not upload image</h1>';
$errors=1;
}

}
}
}
}

enter image description here

^^^^ 缺少更多图片

最佳答案

您上传的图片已被截断,因此可以假设文件未完成上传。也许服务器上的临时目录已满,也许您已超出服务器上的配额。我已经在我的服务器上测试了你的代码,这里没有问题。

关于PHP上传的图像被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14938561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com