Jump to content

uploading picture


runnerjp

Recommended Posts

hey guys... a quickie

 

is there away i can let users upload images and then have them set as there profile picture for every 1 to see??

 

you know like myspace or facebook all these popular profile sites or like on here the avatars.... i say is there away obviously there is,,, i should by saying how?? lol

Link to comment
Share on other sites

Extremely easy using a MySQL database. Assuming you have a users table where you store a unique identifier, you simply tie that image to the particular user. This requires only a minimal understanding of PHP/MySQL so I suggest running through some quick tutorials with working examples. I don't think giving you code would help.

Link to comment
Share on other sites

This is done in a very easy fashion, byt I agree with Ceasar, providing code here would only hinder your learning process.

 

I will give you an idea of how I did it. I have a fully database driven application for church directories, attendence, service information, family directories, individual profiles, etc etc. Each image is in the Images/profiles/pics/ directory, and the image file name is the person's database ID number, which is always unique, .jpg. Or, the person who's ID number is 365, their profile images is 365.jpg.

 

When the file is uploaded, it is moved to Images/profiles/pics/365.jpg. Any time their profile page is opened, PHP checks to see if the file is available, with if(fileexists(...path/to/image)).

 

Hope that helps a little. In cases like this, it is really unique to your style and application.

Link to comment
Share on other sites

<?
		$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
		$sql = "SELECT * FROM $tbl_images WHERE directory = \"$directory\" AND default_pic = \"yes\"";
		$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
		$PICSnum=mysql_num_rows($result);
		while ($row = mysql_fetch_array($result)) {
		$url = $row['url'];
		$image = $row['image'];
		}
		if(empty($url)) {$newurl="$imgdir";}else{$newurl="$userdir/$url";}
		if(empty($image))$image="pic.gif";
		$showimg="/$newurl/$image";
            ?>
            <script type="text/javascript">
		function openpopup(popurl){
		var winpops=window.open(popurl,"","width=610px,height=625px,resizable")
		}
            </script>
            <p align="center">
             <a href="javascript:openpopup('showpic.php?img=<?echo $image ?>')"><IMG SRC="../../thumbs/phpThumb.php?src=<?echo $showimg ?>&w=150" border="0"></a>
             <?
             if($PICSnum > "0") {
             ?>
             <br><a href="<?echo $PHP_SELF ?>?action=pics">My Pictures >></a>
             <? }
                        if($profile_id == $auth[member_id]){
                        echo "<br><a href=\"$userurl/upload.php\">upload picture</a>";
                        
                        ?>

 

thought summats like this but nothing appears on screen but pic.gif thats set as a default pic not the uploaded 1 from the table

Link to comment
Share on other sites

image_id    directory    image    url    displayname    default_pic

 

 

thats what my database is holding.... basicly what i wanna do is get the image from the members id the is loged in at the present time... shouldent this do it...

 

 

so i have someing like this

 

image_id directory                                                 image  url displayname default_pic

00000001  /home/runnerse/public_html/users/Admin  test.jpg  Admin    Admin              yes

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.