我有一个上传图片的表单 < 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;
}
}
}
}
}
^^^^ 更多图片丢失