0
Hi, I’m trying to upload a BD file. ICO, I thought if I only included the extension. ICO in the UPLOAD file would suffice, but pure mistake mine.
So I ask the question:
Is there any way to Upload a Favicon in Format . ICO? If there is a way to adapt the upload file below:
<?php
if(isset($_POST['favicon'])){
//INFO IMAGEM
$file = $_FILES['favicon'];
$numFile = count(array_filter($file['name']));
//PASTA
$folder = '../upload';
//REQUiSITOS
$permite = array('image/jpeg', 'image/png', 'image/gif', 'image/ico');
$maxSize = 1024 * 1024 * 5;
//MENSAGEM
$msg = array();
$errorMsg = array(
1 => 'O arquivo no upload é maior que o Limite de finido em upload_maxsize',
2 => 'O arquivo ultrapassa o limite de tamanho em Max_file_size',
3 => 'O upload do arquivo foi feito parcialmente',
4 => 'Não foi feito o upload do arquivo',
);
if($numFile <= 0)
echo 'Selecione uma Imagem!!';
else{
for($i = 0; $i < $numFile; $i++){
$name = $file['name'][$i];
$type = $file['type'][$i];
$size = $file['size'][$i];
$error = $file['error'][$i];
$tmp = $file['tmp_name'][$i];
$extensao = @end(explode('.', $name));
$novoNome = rand().".$extensao";
if($error != 0)
$msg[] = "<b>$name :</b> ".$errorMsg[$error];
else if (!in_array($type, $permite))
$msg[] = "<b>$name :</b> Erro imagem não suportada!";
else if($size > $maxSize)
$msg[] = "<b>$name :</b> Erro imagem ultrapassa o limite de 5MB!";
else{
if(move_uploaded_file($tmp, $folder."/".$novoNome))
$favicon = $_FILES['favicon'];
$update = mysql_query("UPDATE pagcabecalho SET favicon = '$novoNome' WHERE codigo = '$codigo'");
if($update == ''){
echo "<script language='javascript'>
window.alert('Erro ao atualizar Imagem!!!');
</script>";
}else{
echo "<meta http-equiv='refresh' content='0; URL= ../admin/interna.php'>
<script language='javascript'>
window.alert('Imagem atualizada com sucesso!');
</script>";
}}}}}
?>
Thanks in advance for the attention of all my doubts.
The first question I have is why do you want to put a favicon in the database?
– Jorge B.
I am trying to create an administrative panel of Site, and would like to offer the user the option of being able to insert the favicon as desired. But I’ve found that you don’t necessarily want a file with extension . ICO, I was able to find that with . JPG also works. But thank you for your interest.
– Murilo Cabral
Murilio but you can also save the images to a folder and save only the path to the folder in the database...
– Jorge B.