non mi funziona il form di invio immagini, ovvero mi lascia l'allegato in .dat e non me lo converte in .jpeg
ecco il codice
<?php
session_start();
include("auth.php");
$connection=mysql_connect("***")or die("non trovo il database");
$scegli_db=mysql_select_db(***,$connection) or die ("non trovo la tabella");
$nome_destinatario = "Marco Scarpa";
$nome_mittente = "Gestione Foto";
$titolo = "Cambio di fotografia, $tipoinserimento, $inserimento, $modifica, $cancellazione";
$body = "$nickname - $tipoinserimento, $inserimento, $modifica, $cancellazione";
$email_dest = "redazione@gayspace.it";
$attachment = $_FILES['file']['tmp_name']; // qui si vede che ho rinominato il tuo campo
$attachment_name = $_FILES['file']['name'];
if (is_uploaded_file($attachment)){ // se ho caricato un file...
$fp = fopen($attachment, "rb"); // lo apro
$data = fread($fp, filesize($attachment)); // lo leggo
$data = chunk_split(base64_encode($data)); // lo trasformo nell'unico formato che può essere emailato
fclose($fp);
}
// headers email... impossibile impararli tutti... salvali x uso futuro
$headers = "From: $nome_mittente<redazione@gayspace.it>\n"; // from... si capisce
$headers .= "Reply-To: <redazione@gayspace.it>\n"; // a chi rispondo con "reply"?
$headers .= "MIME-Version: 1.0\n"; // versione mime
$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; // spiego che c'è attachment
$headers .= "X-Sender: $nome_mittente<redazione@gayspace.it>\n"; // sender email
$headers .= "X-Mailer: SCARPAMAILER\n"; // usa la fantasia
$headers .= "X-Priority: 1\n"; // metti 1 e la fai urgente
$headers .= "Return-Path: <redazione@gayspace.it>\n"; // per il reply...
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; // se metti text/html mandi messaggi html
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
$message .= "$body\n";
$message .= "\n";
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
$message .= $data; // virtualmente questo è l'attachment
$message .= "\n";
$message .= "------=MIME_BOUNDRY_main_message--\n";
mail('redazione@gayspace.it', $titolo, $message, $headers);
?>
come posso fare?