Helo, I have a problem with a variable $folder
inside PHP echo code for mailsender. Everything is ok, but the code doesn't display an image, probably I made a mistake here.
<?php
if(isset($_POST['submit'])){
$to = "mail@my.mail.com"; // this is your Email address
$from = "MYSELF"; // this is the sender's Email address
$first_name = "A";
$last_name = "B";
$subject = "Hello!";
$subject2 = "X";
$headers = "From:" . $from;
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-Type: text/html; charset=UTF-8\r\n";
$message= "
<tr>
<td><b>Subname</b></br>".$_POST["Subname"]."</td>
<td rowspan='10'></br><img src='".$folder."'width='200' height='200'></td>
</tr>";
mail($to,$subject,$message,$headers);
}
?>
In normal PHP code I have this and image is showed properly, but I move the "echo" to $message
in mailsender it doesn't work.
<?php
if(isset($_POST['submit'])){
$file_name = $_FILES['file']['name'];
$temp_name = $_FILES['file']['tmp_name'];
$folder = "upload/".$file_name;
move_uploaded_file($temp_name, $folder);
echo "<img src='$folder' width='200' height='200'>";
}
?>
You your second PHP code, $folder
is pointing to a directory and it works correctly.
But for it to work in your $message
, $folder needs to be a link to the image. Something like http://example.com/image.png
<?php
if(isset($_POST['submit'])){
$folder = "http://example.com/image.png";
$to = "mail@my.mail.com"; // this is your Email address
$from = "MYSELF"; // this is the sender's Email address
$first_name = "A";
$last_name = "B";
$subject = "Hello!";
$subject2 = "X";
$headers = "From:" . $from;
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-Type: text/html; charset=UTF-8\r\n";
$message= "
<tr>
<td><b>Subname</b></br>".$_POST["Subname"]."</td>
<td rowspan='10'></br><img src='".$folder."'width='200' height='200'></td>
</tr>";
mail($to,$subject,$message,$headers);
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.