PDA

View Full Version : Please HELP with PHP


Karlein
07-01-2003, 04:36 PM
Can somebody please take a look @ my code......
When file(.doc) is uploaded the file must be send by mail.
So i tried it with mail function.....But the problem is that that it generates the text to a word document and then put it as an attachment in mail. I want that the file after uploading is send to e-mail adress. I hope somebody can help me !!


<?php
// prevent cahing of the php file
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always changed
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0

$max_size = 50000; // 50kb
$dirname = 'doc'; // path to files destination starting from script directory
$attachment = "$dataLC";

$fichier = $_FILES['fichier'];
$fichier_name = $_FILES['fichier']['name'];
$fichier_type = $_FILES['fichier']['type'];
$fichier_size = $_FILES['fichier']['size'];
$fichier_temp = $_FILES['fichier']['tmp_name'];

// ( fichier is file )
// first of all if it is about an image one recupere a table the caracteristiques ones of the image for the tests
if (isset($fichier))
$tab = filesize($fichier_temp);

// test filesize error
if ($fichier_size > $max_size || $fichier_size == 0)
echo "$status=the format of the file is incorrect";
// test if error in the variable $$fichier
else if (!$fichier || $fichier == "none")
echo "$status=the format of the file is incorrect";
else if (strpos($fichier_name, "\\") || strpos($fichier_name, "/"))
echo "$status=the format of the file is incorrect";
// test file extensions even if the test is not very secure it's one more test :o)
else if (!stristr($fichier_name, ".doc"))
echo "$status=the format of the file is incorrect";
else
{
// everything went ok, pfew finally we can upload the file with copy
copy($fichier_temp, $dirname . "/" . $fichier_name) or die("&status = error");
echo $status = 0;
}

// here's what the server page needs to send back whatever the language is
// CHECK THE MAIL FUNCTION PLEASE.......THE UPLOADED FILR MUST BE SEND BY E_MAIL
echo "<HTML><BODY><script>window.top.upLoadEnd('$browseLC',$status,'$fichier _name','$dataLC')</script></HTML>";
mail("email@email.com","subject","This must be plain/text message with no conflict to word document","Attachment: $attachment\n"."Content-type: Application/Octet-stream; name=voorstelsporthal.doc\n"."Content-disposition: Attachment; voorstelsporthal.doc\n"."Content-transfer-encoding: BASE64\n"."Importance: High\n"."X-Priority: 1\n"."X-Priority: 1\n") or die("$status = mail not send");
echo "$status=o.k.";
?>


Please help.....it's driving me crazy !!!
Thanx in advance....

Greetz,

Karlein

Karlein
07-02-2003, 11:13 PM
Ohhh......guys.............Sorry 4 bad post !! It was very late....
But got all things working......Pretty nice though !!!
It uploads the attachment in flash to directory and mails the attachment from directory to e-mail adress !!! Pretty nice !!!
It's based on the Yamzbrowser script.......Thanx

Greetz,

Karlein

Interested in the code.............??? Send me a pm.

Karlein
07-02-2003, 11:31 PM
Ohhh......guys.............Sorry 4 bad post !! It was very late....
But got all things working......Pretty nice though !!!
It uploads the attachment in flash to directory and mails the attachment from directory to e-mail adress !!! Pretty nice !!!
It's based on the Yamzbrowser script.......Thanx

Greetz,

Karlein

Interested in the code.............??? Send me a pm.