I got this script for creating an HTML page from an image uploader, The only problem is that it overwrite's itself on every upload, I would like to change it so that I get sent an e-mail instead.
Ideas?
<?php
$destination_dir = "uploaded/";
$targetPath = dirname($_SERVER['SCRIPT_URI']) . "/";
$html_start = "
<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<title>Upload results</title>
</head>
<body>
";
$html_end = "
</body>
</html>
";
// Check if there are AdditionalStringVariable
$result = "AdditionalStringVariable: " . $_POST["AdditionalStringVariable"];
$result .= "<br>";
// Process value of QIU_thumbnails_Imagedata field, this is JPEG-files array of generated thumbnails
if($_FILES[QIU_thumbnails_Imagedata])
{
foreach ($_FILES[QIU_thumbnails_Imagedata][name] as $key => $value)
{
$uploadfile = $destination_dir . basename($_FILES[QIU_thumbnails_Imagedata][name][$key]);
if (move_uploaded_file($_FILES['QIU_thumbnails_Imagedata']['tmp_name'][$key], $uploadfile))
{
$big_image_name = $_FILES[Imagedata][name][$key];
$result .= "<a href='" .$big_image_name. "'>" . "<img border = '0' src='".$value . "'/></a><br><br>";
}
}
}
//
$result .= "<br>";
// Process value of Imagedata field, this is JPEG-files array
foreach ($_FILES[Imagedata][name] as $key => $value)
{
$uploadfile = $destination_dir . basename($_FILES[Imagedata][name][$key]);
if (move_uploaded_file($_FILES['Imagedata']['tmp_name'][$key], $uploadfile))
{
$result .= "File uploaded: <a href='". $value . "'>" . $value . "</a><br>";
}
}
//
$result .= "<br>";
//
// Process GlobalControlData field, this is the array of serialized data for Global controls
// the value for each control is: id|value
if($_POST[GlobalControlData])
{
foreach ($_POST[GlobalControlData] as $key => $value)
{
$globalControlExploded = explode("|", $value);
$result .= "\n" . "GlobalControlData:\n\t" . $globalControlExploded[0] ."\t:\t" . $globalControlExploded[1] . "<br>";
}
}
//
// Process LocalControlData field, this is the array of serialized data for Local controls
// value for each image is: image||id1|value1^id2|value2^id3|value3, where image - is picture name, id - is unique control ID , and a value - control value
if($_POST[LocalControlData])
{
foreach ($_POST[LocalControlData] as $key => $value)
{
$exploded = explode("||", $value);
$parentFile = $exploded[0];
$result .= "<br>" . $exploded[0] . "<br>";
$explodedToControls = explode("^", $exploded[1]);
foreach ($explodedToControls as $cnt => $val)
{
$eachControl = explode("|", $val);
$result .= "\tcontrol:\t" . $eachControl[0] . ", value:\t" . $eachControl[1] . "<br>";
}
//
}
}
//
$result = $html_start . $result . $html_end;
//
if(@$fp = fopen($destination_dir.'index.html', 'w')) {
fwrite($fp, $result);
fclose($fp);
}
132 echo $targetPath . $destination_dir;
133
134 ?>
I just added this:
135
136 $to = '[email protected]';
137 $subject = 'Baublet Order Received';
138 $headers = 'From: [email protected] '. "\r\n" .
139 'MIME-Version: 1.0' . "\r\n" .
140 'Content-type: text/html; charset=utf-8' . "\r\n";
141 mail($to, $subject, $result, $headers");
142
143 ?>