Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

HyperFast

como eu...

Recommended Posts

Olá galera!!!

 

Seguinte, tenho esse form de upload aki, mas eu queria q quando a pessoa mandasse algo eu recebesse um e-mail informando isso....

exemplo:

clica no botão envia

eu recebo um mail: Arquivo enviado ao servidor

 

Tem como?!

 

Segue o código:

 

PHP [/tr][tr]<!-- put all in upload.php file -->

<form action="upload.php" method="post" enctype="multipart/form-data">

 <p><br>

   <input type="file" name="filetoupload" value="Procurar arquivo">

   <br>

   <input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">

   <br>

   <input type="Submit" value="Enviar">

</p>

 <p>  </p>

 <p>     </p>

</form>

 

<?php

/*  Description -----------------------------------------------------

The Super Global Variable $_FILES is used in PHP 4.x.x.

$_FILES['upload']['size'] ==> Get the Size of the File in Bytes.

$_FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File.

$_FILES['upload']['name'] ==> Returns the Actual Name of the File.

$_FILES['upload']['type'] ==> Returns the Type of the File.

 

So if I filetoupload the file 'test.doc', the $_FILES['upload']['name']

would be 'phptut.doc' and $_FILES['upload']['type'] would be 'application/msword'.

---------------------------------------------------------------------*/

// this is the upload dir where files will go.

//Don't remove the /

//Chmod it (777)

$upload_dir = "ftp/clientes/";   //change to whatever you want.

// files less than 1MB

$size_bytes = 10000000000048576; //bytes  will be uploaded

//check if the directory exist or not.

if (!is_dir("$upload_dir")) {

die ("O diretorio <b>($upload_dir)</b> nao existe");

}

//check if the directory is writable.

if (!is_writeable("$upload_dir")){

       die ("O diretorio <b>($upload_dir)</b> nao esta disponivel no momento, Chmod (777)");

}

 

//Check first if a file has been selected

//is_filetoupload_file('filename') returns true if

//a file was filetoupload via HTTP POST. Returns false otherwise.

if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))

{

 

//Get the Size of the File

$size = $_FILES['filetoupload']['size'];

//Make sure that $size is less than 1MB (1000000 bytes)

if ($size > $size_bytes)

{

echo "Arquivo muito grande. contate-nos.";

exit();

 

}

// $filename will hold the value of the file name submetted from the form.

$filename =  $_FILES['filetoupload']['name'];

// Check if file is Already EXISTS.

if(file_exists($upload_dir.$filename)){

  echo "Oops! Ja existe um arquivo com o nome <b>$filename </b>";

  exit();

}

 

//Move the File to the Directory of your choice

//move_filetoupload_file('filename','destination') Moves an filetoupload file to a new location.

if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$upload_dir.$filename)) {

 

//tell the user that the file has been filetoupload

echo "Arquivo (<a href=$upload_dir$filename>$filename</a>) enviado com sucesso!";

exit();

 

}

else

{

//Print error

echo "Houve um problema no envio";

exit();

 

}

}

 

?>

[/tr]

 

aliás esse code é baum pacas, quem quiser fique a vontes de pegar!!! ;)

Compartilhar este post


Link para o post
Compartilhar em outros sites

soh coloca isso no código:

 

PHP [/tr][tr]$mensagem = "O arquivo $filename foi enviado para o servidor";

mail("seu@email.com", "Novo arquivo enviado ao servidor!", $mensagem,

"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .

"X-Mailer: PHP/" . phpversion());

}

[/tr]

 

antes disso:

 

PHP [/tr][tr]else

{

//Print error

echo "Houve um problema no envio";

exit();

 

}

}

[/tr]

Compartilhar este post


Link para o post
Compartilhar em outros sites

nossa, muito obrigado mesmo, amanhã vou testar!!!valew!!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.