这里有一个非常奇怪的问题。是我上传照片的时候。当我上传照片时总是出现错误: 警告:getimagesize(C:\xampp\tmp\php2D6C.tmp):无法打开流:C:\xampp\htdocs\classes\Funcoes.php 中没有这样的文件或目录第 545 行
当我转到第 545 行时,它是“getimagesize()”方法。好吧,发生错误,但我实际上可以上传照片。我已经更改了很多次并且也删除了。
我做错了什么?(是的,权限是777)
function UploadImagem()
{
$Mensagem = "";
$Error = array();
$Data = new Database();
$Usuario = $_SESSION["sessionUsuario"];
$Foto = $_FILES["change_foto"];
if (!empty($Foto["name"]))
{
$Largura = 1000;
$Altura = 1000;
$Tamanho = 350000; // 1000 = 1kb
if(!preg_match("/^image\/(pjpeg|jpg|jpeg|png|gif|bmp)$/", $Foto["type"]))
{
$Error[1] = "This is not an image.";
}
$Dimensoes = getimagesize($Foto["tmp_name"]); // LINE 545
if($Dimensoes[0] > $Largura)
$Error[2] = "The max image width is " . $Largura . " pixels.";
if($Dimensoes[1] > $Altura)
$Error[3] = "The max image height is " . $Altura . " pixels.";
if($Foto["size"] > $Tamanho)
$Error[4] = "The max image size is " . $Tamanho . " bytes (or " . $Tamanho/1000 . " kilobytes).";
if (count($Error) == 0)
{
$Data->Conecta();
$PegarUsuarioID = "SELECT id_usuario, foto FROM usuarios WHERE nick = '$Usuario'";
$ResulPegarUsuarioID = mysql_query($PegarUsuarioID, $Data->link) or die (mysql_error());
$UsuarioID = mysql_result($ResulPegarUsuarioID, 0, 'id_usuario');
$FotoUsuario = mysql_result($ResulPegarUsuarioID, 0, 'foto');
preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $Foto["name"], $ext);
$NomeImagem = $UsuarioID . "." . $ext[1];
$PathImagem = "../uploads/images/" . $NomeImagem;
if (move_uploaded_file($Foto["tmp_name"], $PathImagem))
{
$InserirFotoUsuario = "UPDATE usuarios SET foto = '$NomeImagem' WHERE id_usuario = $UsuarioID";
$ResulInserirFotoUsuario = mysql_query($InserirFotoUsuario, $Data->link) or die (mysql_error());
}
$Data->Desconecta();
return "Correto";
}
else
{
foreach ($Error as $Erro)
$Mensagem .= $Erro . "<br />";
return $Mensagem;
}
}
}
错误在此方法“UploadImagem()”中。先谢谢了。