Ir para conteúdo
Fórum Script Brasil
  • 0

imagem salva dentro de um diretorio


arldin

Pergunta

Bom dia a todos

eu tenho este script que da upload na imagem e cria imagem thumbs

ate ai tudo beleza as imagem são gravada nos diretorios

o que eu estou querendo e que as mesmas imagem foce para um db

este e o script

<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title></title>
</head>

<body >
<?

// Below lines are to display file name, temp name and file type , you can use them for testing your script only//////
echo "Arquivo nome: ".$_FILES[userfile][name]."<br>";
echo "link nome: ".$_FILES[userfile][tmp_name]."<br>";
echo "Arquivo tipo: ".$_FILES[userfile][type]."<br>";
echo "<br><br>";
///////////////////////////////////////////////////////////////////////////
$add="upimg/".$_FILES[userfile][name]; // the path with the file name where the file will be stored, upload is the directory name. 
//echo $add;
if(move_uploaded_file ($_FILES[userfile][tmp_name],$add)){
echo "Carregado com sucesso";
chmod("$add",0777);

}else{echo "Falha ao carregar arquivo";
exit;}

///////// Start the thumbnail generation//////////////
$n_width=100;          // Fix the width of the thumb nail images
$n_height=100;         // Fix the height of the thumb nail imaage

$tsrc="thimg/".$_FILES[userfile][name];   // Path where thumb nail image will be stored
//echo $tsrc;
if (!($_FILES[userfile][type] =="image/pjpeg" OR $_FILES[userfile][type]=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$_FILES[userfile][type]=="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im);              // Original picture width is stored
$height=ImageSy($im);                  // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////

////////////// starting of JPG thumb nail creation//////////
if($_FILES[userfile][type]=="image/pjpeg"){
$im=ImageCreateFromJPEG($add); 
$width=ImageSx($im);              // Original picture width is stored
$height=ImageSy($im);             // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);                 
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
////////////////  End of JPG thumb nail creation //////////
?>


<center><a HREF="addimg.php">Enviar mais imagem</a></center> 
</body>

</html>

e esta seria a tabela que eu gostara que ela foce salva

CREATE TABLE `tbl_imagens` (

`id_imagem` int(11) NOT NULL auto_increment,

`imagem_grd` varchar(150) NOT NULL default,

`imagem_thumb` varchar(150) NOT NULL default,

`status` varchar(10) NOT NULL default,

PRIMARY KEY (`id_imagem`)

);

agradeço a todos pela força

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Você tem que fazer um insert na tabela agora, te aconselho a aprender um pouco sobre SQL, programar não é só copiar e colar , existem um conceito que você precisa entender.

De uma olhada em:

http://www.w3schools.com/sql/sql_insert.asp

Boa sorte!!

Desenvolvimento freelance de aplicações Web e Desktop em PHP, VB6, C#

http://returnvoid.com.br

Editado por Return Void
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...