0
您好我有這樣一段代碼:PHP表單文件上傳NONAME文件
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$address2 = $_POST['address1'];
$zip = $_POST['zip'];
$delivery = $_POST['delivery'];
$represents = $_POST['represent'];
$npairs = $_POST['npairs'];
$cuff = $_POST['cuff'];
$notes = $_POST['Text'];
// Headers
$headers = "From: $email";
// create a boundary string. It must be unique
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$fileatt = $_FILES['artwork1']['tmp_name'];
$fileatt_type = $_FILES['artwork1']['type'];
$fileatt_name = $_FILES['artwork1']['name'];
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$interested = stripcslashes($interested);
$message = " $todayis [EST] \n
From: $name \n
e-mail: $email \n
Phone: $phone \n
Company: $company \n
Phone: $phone\n
Address: $Address\n
State/Providence: $address2\n
Zip code: $zip
Country: $delivery
Represents: $represents
Number of pairs: $npairs
Style of Socks: $cuff
Message: $notes \n
";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
);
mail("[email protected]", 'My tittle', $message,$headers);
?>
但由於某些原因,當我收到它在我的電子郵件中的附加文件上有我recive無信息「NONAME」。沒有擴展或任何..會有人知道我做錯了什麼?
我確實收到的那些變量是備註良好的文件...:S(沒有任何成功完成) – 2012-07-23 15:24:00