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 7582427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:25:57+00:00 2026-05-30T18:25:57+00:00

Some please help me with coding the below piece! So at the moment I

  • 0

Some please help me with coding the below piece!

So at the moment I have a place where members can set up a profile that displays all there information. I now want to give the user an option to upload images. and have a personal Gallery area.

All the tutorials i seem to find only show me how to do an image upload. And not specific to users that there gallery area will have other peoples work in it.

I assume this will need a database to make it user specific? or work off the $_SESSION variable? I just dont know how to go about doing this.

im totally lost can someone point me in the right direction?

Below is my current gallery.php code which just pretty much generates thumbnails and displays all given images in the uploads folder.

How would I go about editing this just to display images for the user in a session or given user profile?

    <?php
if (isset($_GET['img'])){
    //make thumbnail
    if(file_exists($_GET['img'])){
        ignore_user_abort(true);
        set_time_limit(120);
        ini_set('memory_limit', '512M');

        $src_size = getimagesize($_GET['img']);

        if ($src_size === false){
            die('That does not look like an image.');
        }

        $thumb_width    = 200;
        $thumb_height   = 150;

        if ($src_size['mime'] === 'image/jpeg'){
            $src = imagecreatefromjpeg($_GET['img']);
        }else if ($src_size['mime'] === 'image/png'){
            $src = imagecreatefrompng($_GET['img']);
        }else if ($src_size['mime'] === 'image/gif'){
            $src = imagecreatefromgif($_GET['img']);
        }

        $src_aspect = round (($src_size[0] / $src_size[1]), 1);
        $thumb_aspect = round(($thumb_width / $thumb_height), 1);

        if ($src_aspect < $thumb_aspect){
            //higher than thumb
            $new_size = array ($thumb_width, ($thumb_width / $src_size[0]) * $src_size[1]);
            $src_pos = array (0, (($new_size[1] - $thumb_height) * ($src_size[1] / $new_size[1])) / 2);
        }else if ($src_aspect > $thumb_aspect){
            // wider than thumb
            $new_size = array(($thumb_width / $src_size[1] ) * $src_size[0], $thumb_height);
            $src_pos = array((($new_size[0] - $thumb_width) * ($src_size[0] / $new_size[0])) / 2, 0);
        }else{
            // same shape as thumb
            $new_size = array($thumb_width, $thumb_height);
            $src_pos = array(0, 0);
        }

        if ($new_size[0] < 1) $new_size[0] = 1;
        if ($new_size[1] < 1) $new_size[1] = 1;

        $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
        imagecopyresampled($thumb, $src, 0, 0, $src_pos[0], $src_pos[1], $new_size[0], $new_size[1], $src_size[0], $src_size[1]);

        if ($src_size['mime'] === 'image/jpeg'){
            imagejpeg($thumb, "thumbs/{$_GET[ 'img' ]}");
        }else if ($src_size['mime'] === 'image/png'){
            imagepng($thumb, "thumbs/{$_GET[ 'img' ]}");
        }else if ($src_size['mime'] === 'image/gif'){
            imagegif($thumb, "thumbs/{$_GET[ 'img' ]}");
        }

        header("Location: thumbs/{$_GET[ 'img' ]}");
    }

    die();
}

if (is_dir('./thumbs') === false){
    mkdir('./thumbs', 0744);
}

$images = glob('*.{jpg, jpeg, png, gif}', GLOB_BRACE);

?>

            <?php

            foreach ($images as $image){
                if (file_exists("./thumbs/{image}")){
                    echo "<a href=\"{$image}\"><img src=\"thumbs/{$image}\" alt=\"{$image}\" /></a>";
                }else{
                    echo "<a href=\"{$image}\"><img src=\"?img={$image}\" alt=\"{$image}\" /></a>";

                }
            }

            ?>
  • 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-05-30T18:25:58+00:00Added an answer on May 30, 2026 at 6:25 pm

    I have one suggestion for you.
    Create one table for “Gallery”
    and insert data about image name and also user_id and this user_id
    will be id of logged user and that you can fetch from session when
    specific user is logged in. This is the way you can manage your image
    gallery with specific user is logged in. Let me know if you need more
    help.. Cheers

    <?php
       $uid = $_SESSION['uid'];
       $query = mysql_query("SELECT * FROM images WHERE user_id=".$uid);
     ?>
    

    Here, you can use above result set for display images for specific user only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help! I have some form elements in a div on a page: <div
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
I need some help with a LINQ query in VB.Net, please. I have this
I do not have much experience coding systems dealing with web-services. Please help me
I am getting a little confused and need some help please. Take these two
Please suggest some free tools which will help me to get Lines-of-Code metrics for
I need some help! Please. I am trying to develop a very very simple
I need some with help with PowerShell, please. It should be pretty easy: I
Can I add Java portlet in sharepoint 2007? If yes, can some please explain
Some one please tell me how to handle RunTimeExceptions in grails version1.1 .I have

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.