display the image uploaded using session id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanspeare
    New Member
    • May 2014
    • 20

    display the image uploaded using session id

    I have uploaded an image using the student_id as its filename. The student id is auto-incremented and unique per student_id. Now i am confused why it gives me problem to display it. I have tried.

    Code:
      <?php print '<img src="uploads/'.$session_id.'" />' ?>
    
      <?php print '<img src="uploads/'.$session_id.".".$ext'" />' ?>
    
      <?php print '<img src="uploads/'.$student_id.'" />' ?>
    
      <img src='uploads/".$actual_image_name."' class='profile-photo' align="middle"> //where $actual_image_name = $student_id.".".$ext;
    but still the image wont display
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    #2
    You did not put php tag in your image src.
    Code:
    <img src="uploads/<?php echo $actual_image_name; ?>" class="profile-photo" align="middle">

    Comment

    • hanspeare
      New Member
      • May 2014
      • 20

      #3
      hi Exequiel,

      I tried your codes but it shows me errors and the rest of the page wont display. i revised it and this is my complete codes now. A working page but the image still wont display.

      Code:
      <?php 
      $actual_image_name = time().".";
      mysql_query("UPDATE users SET profile_image='$actual_image_name' WHERE student_id='{$_SESSION['user_id']}'",$link_id);
      echo "<img src='uploads/".$actual_image_name."'  class='profile-photo'>";
      ?>

      Comment

      • Exequiel
        Contributor
        • Jul 2012
        • 288

        #4
        did you save to your database if what extension type your image are? like filename.jpg/jpeg/png/bmp/gif etc.

        Comment

        • hanspeare
          New Member
          • May 2014
          • 20

          #5
          @Exequiel:

          Yes file name extensions like jpg, png, and gif are being accepted. I suspect the code

          $actual_image_n ame = time().".";

          ,,is wrong in

          time()

          becuase the time of upload and the time of display is not same,,would it matter? if it matters? Can you suggest me a filename to use for the uploaded file so that i can call and display it easily??

          Comment

          • Exequiel
            Contributor
            • Jul 2012
            • 288

            #6
            yes it matters, because in your displaying you used time() function so that result to the time right now but the time you inserted to database is different, must better if you get the value that you inserted to database (the image name in table) than to use time() function in displaying.

            Comment

            • hanspeare
              New Member
              • May 2014
              • 20

              #7
              thank you very much for the patience Exequiel, finally i solve it with the help of your confirmation.

              Comment

              Working...