PHP图像不';不显示,
图像存储在数据库中,每次我在网页上上载图像时,数据库都会工作并更新数据库配置文件部分,但不会显示在web浏览器上。:/我尝试了不同的浏览器,但每个浏览器都无法显示图像,图像的Alt参数确实显示但没有图像,我检查了页面元素图像路径在那里,但我看不到那里的图像 配置文件页面中的代码为:PHP图像不';不显示,,php,css,image,Php,Css,Image,图像存储在数据库中,每次我在网页上上载图像时,数据库都会工作并更新数据库配置文件部分,但不会显示在web浏览器上。:/我尝试了不同的浏览器,但每个浏览器都无法显示图像,图像的Alt参数确实显示但没有图像,我检查了页面元素图像路径在那里,但我看不到那里的图像 配置文件页面中的代码为: <?php function change_profile_image($userID, $file_temp, $file_extn) { $file_path ='C:/xampp/htdocs/crick
<?php
function change_profile_image($userID, $file_temp, $file_extn) {
$file_path ='C:/xampp/htdocs/cricket/user/images/profile/'. substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
mysql_query("UPDATE `user` SET `profile` = '" . mysql_real_escape_string($file_path) . "' WHERE `userID` = " . (int)$userID);
}
?>
<?php
$query = "select * from user where userID='".$_SESSION['id']."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result)
?>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<div id="content">
<h1>Edit Your Information</h1>
<div class="profile">
<?php
if (isset($_FILES['profile'])=== true) {
if (empty($_FILES['profile']['name']) === true) {
echo "Please choose a file!";
} else {
$allowed = array('jpg', 'jpeg', 'gif', 'png');
$file_name = $_FILES['profile']['name'];
$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['profile']['tmp_name'];
if (in_array($file_extn, $allowed)=== true) {
change_profile_image($_SESSION['id'], $file_temp, $file_extn);
} else {
echo "incorrect file type, Allowed: ";
echo implode(', ', $allowed);
}
}
}
if (empty($row['profile']) === false) {
echo '<img src="', $row['profile'], '" alt="', $row['user_firstname'], '\'s Profile Image">';
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="profile"> <br> <input type="submit">
</form>
</div>
<form method="post" action="">
<div class="txtbox1">Email</div>
<div class="txtbox">
<input type="text" name="email" value="<?php echo $row['user_email']?>"> </div><br><br><br>
<div class="txtbox1">First Name</div>
<div class="txtbox">
<input type="text" name="firstname" value="<?php echo $row['user_firstname']?>"></div><br><br><br>
<div class="txtbox1">Surname</div>
<div class="txtbox">
<input type="text" name="lastname" value="<?php echo $row['user_surname']?>"></div><br><br><br>
<div class="txtbox1">DOB</div>
<div class="txtbox">
<input type="text" name="dob" value="<?php echo $row['user_dob']?>"></div><br>
<div class="txtbox"><input type="submit" value="update" name="update"> </div>
</form>
<?php
if(isset($_POST['update'])){
$query1 = "update user set user_email='".$_POST['email']."', user_firstname='".$_POST['firstname']."', user_surname='".$_POST['lastname']."', user_dob='".$_POST['dob']."' where userID='".$_SESSION['id']."'";
$result1 = mysql_query($query1);
echo "<script>alert('Your Information has been changed SuccessFully..'); window.location = './edit.php';</script>";
}
?>
</div>
如果有人能在正确的方向上指导或帮助我,我将不胜感激。
img
标签中的src
值是多少?服务器对此的响应是什么?您是否已检查映像是否实际位于假定路径中,是否已尝试对路径进行硬编码,并将其与$row['profile']中生成的映像位置进行比较映像源是:=“/cricket/user/images/profile/”我尝试了硬代码web浏览器确实显示了表单,但没有显示图像它显示为损坏的图像为什么在src属性中有逗号?
.profile {
background:white;
border:1px dashed #ccc;
padding:5px;
}
.profile img {
width=100%;
}