PHP图像没有显示,

时间:2015-04-26 23:49:53

标签: php css image

图像存储在数据库中,每当我在网页上传图像时,数据库都会工作并更新数据库配置文件部分,但它不会显示在Web浏览器上。 :/我尝试了不同的浏览器但是每个浏览器都无法显示图像,图像的Alt参数确实显示但没有图像,我已经检查了图像路径在那里的页面元素,但我无法在那里看到图像?

个人资料页面中的代码是:

<?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>

如果有人对CSS感兴趣,那么样式代码就是:

.profile {
background:white;
border:1px dashed #ccc;
padding:5px;
}

.profile img {
width=100%;
} 

如果有人能指导我或帮助我朝着正确的方向前进,我将非常感激

0 个答案:

没有答案