1

Web サービスを作成する際に、画像をメールに送信して表示するにはどうすればよいですか。画像以外のすべてのコンテンツを含むメールを送信できます。イメージコードに誤りがあると思います。誰でもこれで私を助けることができますか? 私のコードは

<?php
$title=$_REQUEST['title'];
$location=$_REQUEST['location'];
$contactname=$_REQUEST['contactname'];
$contactnumber=$_REQUEST['contactnumber'];
$description=$_REQUEST['description'];
$image=$_REQUEST['image'];
if($title)
{
$Image=basename($_FILES['file']['name']);
$Image=str_replace(' ','|',$Image);
$date=date('YmdHis');
$date=str_replace('%20',' ',$date);
$Image=$date.".jpg";
$tmppath="images/".$Image;

move_uploaded_file($_FILES['file']['tmp_name'],$tmppath);
$message1 = ?><html><head></head><body>
<? $message1 .= ?><img src="http://www.website.com/appinstaller/ramaraju/images/<?= $Image ?>" /></body></html>
<?php
$headers = "From: support@";
$headers .= "Content-type: text/html";

//mail($to, $subject, $message, $headers);
//$mailimg = '<img src="http://www.myappdemo.com/appinstaller/ramaraju/services/images/$file"</a>';

 $to = "ramaraju.d@stellentsoft.com";
 $subject = "Hi!";
 $message="Title : $title\r\n Location:$location\r\n Contact name:$contactname\r\n Contact:$contactnumber\r\n Description:$description\r\n file:$Image";



  if (mail($to, $subject, $message, $headers))
  {
  $message=array("messsage"=>"Message successfully sent!");
  } else {
  $message=array("message"=>"Message delivery failed.");
  }
  }
  else
  {
  $message=array("message"=>"provide values");
  }
  echo json_encode($message);



?>
4

1 に答える 1

1

印刷していない src のコードでは<?=$Image ?>なく、これを行う必要があります。<? $Image ?>$Image

したがって、最終的な img タグは

<img src="http://www.myappdemo.com/appinstaller/ramaraju/images/<?=$Image ?>" />

<?<?=短い開始タグと呼ばれ、常に有効になっているわけではありません (short_open_tag ディレクティブを参照してください)

于 2012-04-23T06:02:47.177 に答える