As it happens, I've already got all the code to do this!
php code: (nbu.php, accepts file and emails it to address)
<?php
$dname="TEST";
$dname = $_POST["name"];
if(!isset($_FILES['myfile']))
{
echo "0x";
exit;
}
$upload_file = $_FILES['myfile']['name'];
$upload_file_tmp = $_FILES['myfile']['tmp_name'];
if (move_uploaded_file($upload_file_tmp, $upload_file)) {
echo "1";
} else {
echo "0";
}
$file_path = $upload_file; // server path where file is placed
$file_path_type = "text/html"; // File Type
$file_path_name = "level.nbd"; // this file name will be used at reciever end
$from = "Neon@Bunniez.com"; // [fake] E-mail address of sender
$to = "foo@bar.com"; // E-mail address of reciever
$subject = "New NB Level"; // Subject of email
$message = "A new level from: " . $dname;
$headers = "From: ".$from;
$file = fopen($file_path,'rb');
$data = fread($file,filesize($file_path));
fclose($file);
$rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message .= "\n\n";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$file_path_type};\n" .
" name=\"{$file_path_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$file_path_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data .= "\n\n" .
"--{$mime_boundary}--\n";
if(@mail($to, $subject, $message, $headers)) {
echo "File send!";
} else {
echo 'Failed';
}
?>
AGK code:
con = CreateHTTPConnection()
host = SetHTTPHost(con,"[SERVER]", 0) `CHANGE SERVER
SendHTTPFile( con, "nbu.php", "name=" +GetEditBoxText(name), "custom/" + str(level) + ".nbd")
Do
print("uploading: %"+str(GetHTTPFileProgress(con)))
if GetHTTPResponseReady(con) then exit
sync()
Loop
CloseHTTPConnection(con)
DeleteHTTPConnection(con)