-4

ユーザーが入力したフォームが 1 つあり、その値が別のページに表示される 1 つのプロジェクトに取り組んでいます。別のページで取得したすべてのデータが、そのページに画像を表示できず、画像名のみが表示されます。画像を表示したいのですが、どうすればよいですか?

ページ1

<form action="save.php" class="contact-form" method="post" name="inputname">
<table>
<tr>
<td class="label">Name:</td>
<td><input type="text" class="input-text" name="pname" /></td>
</tr>
<tr>
<td class="label">City:</td>
<td><input type="text" class="input-text" name="pcity" /></td>
</tr>
<tr>
<td class="label">Country:</td>
<td><input type="text" class="input-text" name="pcountry" /></td>
</tr>
<tr>
<td class="label">Email:</td>
<td><input type="text" class="input-text" name="pemail" /></td>
</tr>
<tr>
<td class="label">Upload Your Photo:</td>
<td><input type="file" accept="image/jpg,image/gif" class="input-text" name="pphoto"/></td>
</tr>

ページ 2 save.php

mysql_connect("localhost","root","");
mysql_select_db("my_db");
$p_name=$_POST['pname'];              
$p_city=$_POST['pcity'];
$p_country=$_POST['pcountry'];
$p_email=$_POST['pemail'];
$p_photo=$_POST['pphoto'];


<table>  
<ul>  
<tr>  
<td><li class="image"><img src="<? echo $p_photo; ?>" /></li></td>  
<li class="text">  
<td class="label">  
Name: <? echo $p_name; ?></br>    
City: <? echo $p_city; ?></br>  
Country: <? echo $p_country; ?></br>  
E-Mail: <? echo $p_email; ?></br>  
</td>  
</li>  
</tr>  
</ul>
</table>
4

2 に答える 2

0

画像をファイルとしてアップロードする場合は、 $_FILES 配列を使用する必要があります。そして、アップロードした画像を最初に保存する必要があります。

于 2012-12-27T16:23:46.117 に答える
0
@$file = fopen($_FILES['file'] ['tmp_name'], "r");
@$image = addslashes(fread($file, filesize($_FILES['file']['tmp_name'])));

「ファイル」の代わりにファイル名を使用してください。

于 2013-03-26T06:37:44.860 に答える