Gallery Upload to Avatar

Started on the old forum in January 2010 · view the original in the archive · old links redirect here

8 replies · 883 views · started 16 years ago · 1 min read

7 participants
bOrN2pwn Developer · 230 posts #1

Can any 1 please help me with this code its for lava I want to upload profile pics straight to avatar but im struggling to get the code right please help me..... O and its for WML

BakGat

class Counter {
public:
  void Count();
  int  ReadDisplay();
private:
  int  CurrentCount;
};

External image (may be gone) External image (may be gone) External image (may be gone)

Back up my hard drive? How do I put it in reverse? http://www.hackthissite.org Profile…

Vayne Developer · 106 posts #4
mysql_query("UPDATE lietotaji SET avatar='path_to_file/".$changeable."' WHERE id='".$uid."'");

or smth...

Nous Ne Dansos Pas, Nous Sommes Le Danse.!

riderz Lead · 975 posts #5

Here are an xhtml code u must just convert it

Use this in cpanel or where ever

echo "<a href=\"lists.php?action=upavat&sid=$sid\">»Upload Avatar</a><br/>";

genproc.php

////////////////Upload avatar////////////////////////

else if($action=="upavat"){

addonline(getuid_sid($sid),"Uploading avatar image","");

$size = $_FILES['attach']['size']/1024;

$origname = $_FILES['attach']['name'];

$res = false;

$ext = explode(".", strrev($origname));

switch(strtolower($ext[0])){

        case "gpj":

    $res = true;

    break;

    case "gepj":

    $res = true;

    break;

}

$tm = time();

$uploaddir = "./avatars";

if($size>512){

    echo "File is larger than 512KB";

    

}

else if ($res!=true){

                                    

    echo "File type not supported! Please attach only a JPG/JPEG.";

}

else{

    $name = getuid_sid($sid);

    $uploadfile = $name.".".$ext;

    $uppath=$uploaddir."/".$uploadfile;

    move_uploaded_file($_FILES['attach']['tmp_name'], $uppath);

    $filewa=$uppath;

    list($width, $height, $type, $attr) = getimagesize($filewa);

    $newname=$uploaddir."/".$name."u.jpg";

    $newheight = ($height*128)/$width;

    $newimg=imagecreatetruecolor(128, $newheight);

    $largeimg=imagecreatefromjpeg($filewa);

    imagecopyresampled($newimg, $largeimg, 0, 0, 0, 0, 128, $newheight, $width, $height);

    imagejpeg($newimg, $newname);

    imagedestroy($newimg);

    imagedestroy($largeimg);

    $file1=$name."u.jpg";

    unlink($filewa);

        $res1 = mysql_query("UPDATE ibwf_users SET avatar='./avatars/$file1' WHERE id='".$name."'");

}

if($res1){

    echo "Your file $origname was successfully uploaded and set to your profile!";

}

else {

    echo "File couldn't be processed! Check error messages and report to a moderator or admin if applicable.";

}

}

list.php

///////////////Upload avatar///////////////

else if($action=="upavat"){

        addonline(getuid_sid($sid),"Uploading avatar image","lists.php?action=$action");

        $whonick = getnick_uid($who);

    boxstart("Upload Avatar");

        echo "<p><u>Choose the pic:</u><br/>

        <form enctype=\"multipart/form-data\" action=\"genproc.php?action=upavat&sid=$sid\" method=\"post\">

        Image(JPG/JPEG image only):<br/>Size limit: 512KB<br/>Image will be resized to fit its width to 128 pixels.

        <input type=\"file\" name=\"attach\"/><br/>

        <input id=\"inputButton\" type=\"submit\" name=\"submit\" value=\"Send\"/></form></p>

";

}

Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

Alokmona Newbie · 1 posts #6

riderz wrote: Here are an xhtml code u must just convert it

Use this in cpanel or where ever

echo "<a href=\"lists.php?action=upavat&sid=$sid\">»Upload Avatar</a><br/>";

genproc.php

////////////////Upload avatar////////////////////////


else if($action=="upavat"){

addonline(getuid_sid($sid),"Uploading avatar image","");

$size = $_FILES['attach']['size']/1024;

$origname = $_FILES['attach']['name'];

$res = false;

$ext = explode(".", strrev($origname));

switch(strtolower($ext[0])){

        case "gpj":

    $res = true;

    break;

    case "gepj":

    $res = true;

    break;

}

$tm = time();

$uploaddir = "./avatars";

if($size>512){

    echo "File is larger than 512KB";

    

}

else if ($res!=true){

                                    

    echo "File type not supported! Please attach only a JPG/JPEG.";

}



else{

    $name = getuid_sid($sid);

    $uploadfile = $name.".".$ext;

    $uppath=$uploaddir."/".$uploadfile;

    move_uploaded_file($_FILES['attach']['tmp_name'], $uppath);

    $filewa=$uppath;

    list($width, $height, $type, $attr) = getimagesize($filewa);

    $newname=$uploaddir."/".$name."u.jpg";

    $newheight = ($height*128)/$width;

    $newimg=imagecreatetruecolor(128, $newheight);

    $largeimg=imagecreatefromjpeg($filewa);

    imagecopyresampled($newimg, $largeimg, 0, 0, 0, 0, 128, $newheight, $width, $height);

    imagejpeg($newimg, $newname);

    imagedestroy($newimg);

    imagedestroy($largeimg);

    $file1=$name."u.jpg";

    unlink($filewa);

        $res1 = mysql_query("UPDATE ibwf_users SET avatar='./avatars/$file1' WHERE id='".$name."'");

}

if($res1){

    echo "Your file $origname was successfully uploaded and set to your profile!";

}

else {

    echo "File couldn't be processed! Check error messages and report to a moderator or admin if applicable.";

}



}

list.php

///////////////Upload avatar///////////////

else if($action=="upavat"){

        addonline(getuid_sid($sid),"Uploading avatar image","lists.php?action=$action");

        $whonick = getnick_uid($who);



    boxstart("Upload Avatar");





        echo "<p><u>Choose the pic:</u><br/>

        <form enctype=\"multipart/form-data\" action=\"genproc.php?action=upavat&sid=$sid\" method=\"post\">

        Image(JPG/JPEG image only):<br/>Size limit: 512KB<br/>Image will be resized to fit its width to 128 pixels.

        <input type=\"file\" name=\"attach\"/><br/>

        <input id=\"inputButton\" type=\"submit\" name=\"submit\" value=\"Send\"/></form></p>

";

}

but u forget one thing, the older file must get deleted from avatar folder when new avatar is uploaded, otherwise it will bundle up useless images in the avatar folder.

pmbguy Senior · 344 posts #7

well, possibly not...

cause if you set up a user avatars table, users can have a gallery of uploaded avatars too... you just code it so they can only see the ones they uploaded type thing... I would have done it myself, but i couldn't be bothered, lol... not that significant in my eyes...

subzero Super moderator Fellow · 3,954 posts #9

just add new line update gallery pic button if yes then add it to avatar ! easy...

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close