Dear all,
I have created a website where I would like my users to register and upload profile images to my server and then store it under folder in my server known as "images" and then save the dataurl of the images into MySQL database. Then, I would display their profile picture on a page known as "profile.html" into row and resize the images into 60x60 pixels images.

I have no idea how to do this. I have found and read through a lot of thread ut I did not find any related information.
Anyone can help me with this?

Thanks for any help.

Recommended Answers

All 4 Replies

There many way to do that, you can do that, in php, and get the values from the form and save it to Database and save the image to the folder.

Check bellow the code.



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


  $connection = mysql_connect("localhost","root","");
  if (!$connection) {
    die("Database connection failed: " . mysql_error());

  $db_select = mysql_select_db("test",$connection);
  if (!$db_select) {
    die("Database selection failed: " . mysql_error());

  $slike = array(file, file1, file2, file3, file4);

  $filearray = array();
  $filearray1 = array();

  foreach($slike as $slika){
  $image =$_FILES[$slika]["name"];
  $uploadedfile = $_FILES[$slika]['tmp_name'];
  if ($image)

    $filename = stripslashes($_FILES[$slika]['name']);

      $extension = getExtension($filename);
    $extension = strtolower($extension);

 if (($extension != "jpg") && ($extension != "jpeg") &&
        ($extension != "png") && ($extension != "gif"))

      $change='<div class="msgdiv">Unknown Image extension </div> ';


if ($size > MAX_SIZE*1024)
  $change='<div class="msgdiv">You have exceeded the size limit!</div> ';

if($extension=="jpg" || $extension=="jpeg" )
$uploadedfile = $_FILES[$slika]['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);

else if($extension=="png")
$uploadedfile = $_FILES[$slika]['tmp_name'];
$src = imagecreatefrompng($uploadedfile);

$src = imagecreatefromgif($uploadedfile);

echo $scr;







$filename = "images/". $image_name;

$filename1 = "images/small_". $image_name;



$filearray[$k]= $filename;
$filearray1[$k]= $filename1;

  mysql_query("Insert into tbl_user set user_id='2',
  ap_id='2',big='$filename',small='$filename1' ", $connection);

if(isset($_POST['Submit']) && !$errors)
    $change=' <div class="msgdiv">Image Uploaded Successfully!</div>';

//sql code for user table 

create table 'tbl_user'
'user_id' int,
'ap_id' int,
'big' varchar,

Hi hoppe it can help.

Thanks a lot. I think this has solved major part of my problem. I have some question:
$filename = "images/". $image_name;
$filename1 = "images/small_". $image_name;

The above codes "images/". $image_name has a . $image_name. Is it meaning that if my photo name is ABC.jpeg, the URL to the image will become "images/.ABC.jpeg" ?

Thanks a lot :)

Look, when you save the image, you have 2 different image size.
one is big then another, and you can choose which one you want or you can specify the about width and heigth.
$filename is original size and and $filename1 saving with another size.

the "dot" in a php text variable is concatenation, it means the variable is appended directly to the preceding text
The above codes "images/". $image_name
if your photo name is ABC.jpeg, the URL to the image will be "images/ABC.jpeg"
normally used with 'single quotes' :: "double quoted" text is parsed for variables ,, so may equally look like this "images/$image_name"

you see the .dot in declarations

$a = 'ralph';
$a .= ' wiggum'; // eq to $a = 'ralph'.' wiggum';
echo $a; // ralph wiggum

and many other (non-trivial) instances where it is important to see the development of variables $c=$a.$b;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.