Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:50:26+00:00 2026-06-13T23:50:26+00:00

I have a website in which user upload their profile picture and I have

  • 0

I have a website in which user upload their profile picture and I have stored the pic in a folder and their links are reflected in Database
How do i show that link in the place where i have to show the photo ?

Code for uploading photo

    define ("MAX_SIZE","1000"); 
    function getExtension($str)
    {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
    }

    $errors=0;
    $image=$_FILES['image']['name'];

    if ($image) 
    {

$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") 
    && ($extension != "gif")&& ($extension != "JPG") && ($extension != "JPEG") 
    && ($extension != "PNG") && ($extension != "GIF")) 
{
    echo '<h3>Unknown extension!</h3>';
    $errors=1;
}
else
{
    $size=filesize($_FILES['image']['tmp_name']);

    if ($size > MAX_SIZE*1024)
    {
        echo '<h4>You have exceeded the size limit!</h4>';
        $errors=1;
    }

    $image_name=time().'.'.$extension;
    $newname="photo/".$image_name;

    $copied = copy($_FILES['image']['tmp_name'], $newname);
    if (!$copied) 
    {
        echo '<h3>Copy unsuccessfull!</h3>';
        $errors=1;
    }
    else echo '<h3>uploaded successfull!</h3>';

    //mysql_query("insert into tutor (photo) values('".$newname."')");
    $myphoto= ".$newname.";
}

Code for insertion

    $mysqli = new mysqli("localhost", "***", "***", "***");
    if ($mysqli->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " .                         $mysqli->connect_error;
    }

    /* Prepared statement, stage 1: prepare */
    if (!($stmt = $mysqli->prepare("INSERT INTO `table` (`photo` ) VALUES (  ?)"))) {
        echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
    }

    /* Prepared statement, stage 2: bind and execute */

    if (!$stmt->bind_param('s',$myphoto )) {
        echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
    }

    if (!$stmt->execute()) {
        echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:50:27+00:00Added an answer on June 13, 2026 at 11:50 pm

    You need to link your user to the picture somehow, for example adding a foreign key to your users table, and then inserting the current user ID along with the picture.

    In your upload/insert page you’d end up with something similar to

    // Assuming you're saving your logged in user's data in sessions
    $current_user_id = $_SESSION['user_id'];
    // Assuming you already have a $mysqli variable with an open connection
    $mysqli->exec("INSERT INTO picture_table SET user = $current_user_id, picture = '$picture_file';");
    

    Then, on your profile/display page, you’d have to fetch it from the DB using something similar to

    // Assuming you already have a $mysqli variable with an open connection
    $q = $mysqli->query("SELECT picture WHERE user = $current_user_id");
    $row = $q->fetch_object();
    
    printf('<img src="http://yoursite.com/yourpath/%s"  />', $row->picture);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website which sells a product to the user (downloadable). I am
I have aspx website in which I have multiple user controls. I want to
I have a website, which will be frequently updated. Sometimes changes happen to User
I have a Silverlight web app which uses ASP.net Website administration tool for user
I am making a website which allows users to upload images for their profiles.
I have a website that shows galleries. Users can upload their own content from
I want to write a website which have functions to record user's screen, and
I would like to have an upload control on an intranet website, which needs
I have a website where users sign up and get to upload their images
I have a website which is using SQL SERVER 2008 which allows user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.