title: Why uploader in php .. increase file size?
body: <p>I have an uploader for images and videos ..
  I try to upload 52 images files with 1.38 Mb in size
  but when check it size on my server I found it 5.2 Mb ..
  this is code of php uploader .. can I know where is problem ?</p>
  
  <pre><code>&lt;?php
      if (isset($_FILES['upload_img'])) {
          $uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/upload/img/'; //path you wish to store you uploaded files
          echo '&lt;h2&gt;Image(s) Uploaded&lt;/h2&gt;&lt;ul style="overflow: scroll;height: 200px;"&gt;';
          //Loop through each file
          for($i = 0; $i &lt; count($_FILES['upload_img']['name']); $i++) {
              //Get the temp file path
              $tmpFilePath = $_FILES['upload_img']['tmp_name'][$i];
  
              //Make sure we have a filepath
              if ($tmpFilePath != ""){
                  //Setup our new file path
                  $uploadedFile = $uploadDir . basename($_FILES['upload_img']['name'][$i]);
  
                  //Upload the file into the temp dir
                  $dir = pathinfo($uploadedFile,PATHINFO_DIRNAME);
                  $actual_name = pathinfo($uploadedFile,PATHINFO_FILENAME);
                  $original_name = $actual_name;
                  $extension = pathinfo($uploadedFile, PATHINFO_EXTENSION);
                  $j = 1;
                  while(file_exists($uploadedFile))
                  {           
                      $actual_name = (string)$original_name.$j;
                      $uploadedFile = $dir."/".$actual_name.".".$extension;
                      $j++;
                  }
  
                  $size = getimagesize($tmpFilePath);
                  $ratio = $size[0]/$size[1]; // width/height
  
                  if( $ratio &gt; 1) {
                      $width = 300;
                      $height = 300/$ratio;
                  }
                  else {
                      $width = 300*$ratio;
                      $height = 300;
                  }
                  $src = imagecreatefromstring(file_get_contents($tmpFilePath));
                  $dst = imagecreatetruecolor($width,$height);
                  imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]);
                  imagedestroy($src);
  //              if(move_uploaded_file($tmpFilePath, $uploadedFile)) {               
                  if(imagepng($dst,$uploadedFile)) {
                      $fpath = '/upload/img/' . $actual_name.".".$extension;
                      echo '&lt;li style="list-style:none"&gt;' . $fpath . '&lt;/li&gt;';
                      //save to db
                      save_db_img($fpath, $_POST['cat_value_img']);
                  } else {
                      echo '&lt;h2&gt;There was a problem saving the uploaded file&lt;/h2&gt;';
                  }
                  imagedestroy($dst);
              }
          }
          echo '&lt;/ul&gt;';
      }
  
      if (isset($_FILES['upload_video'])) {
          $uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/upload/video/'; //path you wish to store you uploaded files
          echo '&lt;h2&gt;Video(s) Uploaded&lt;/h2&gt;&lt;ul style="overflow: scroll;height: 200px;"&gt;';
          //Get the temp file path
          $tmpVideoPath = $_FILES['upload_video']['tmp_name'];
          $tmpImgPath = $_FILES['upload_timg']['tmp_name'];
  
          //Setup our new file path
          $uploadedVideoFile = $uploadDir . basename($_FILES['upload_video']['name']);
          $uploadedImgFile = $uploadDir . basename($_FILES['upload_timg']['name']);
  
          $dir = pathinfo($uploadedVideoFile,PATHINFO_DIRNAME);
          $actual_name = pathinfo($uploadedVideoFile,PATHINFO_FILENAME);
          $original_name = $actual_name;
          $extension = pathinfo($uploadedVideoFile, PATHINFO_EXTENSION);
          $j = 1;
          while(file_exists($uploadedVideoFile))
          {           
              $actual_name = (string)$original_name.$j;
              $uploadedVideoFile = $dir."/".$actual_name.".".$extension;
              $j++;
          }
  
          $dir_img = pathinfo($uploadedImgFile,PATHINFO_DIRNAME);
          $actual_name_img = pathinfo($uploadedImgFile,PATHINFO_FILENAME);
          $original_name_img = $actual_name_img;
          $extension_img = pathinfo($uploadedImgFile, PATHINFO_EXTENSION);
          $k = 1;
          while(file_exists($uploadedImgFile))
          {           
              $actual_name_img = (string)$original_name_img.$k;
              $uploadedImgFile = $dir."/".$actual_name_img.".".$extension_img;
              $k++;
          }
  
          //Upload the file into the temp dir
          if(move_uploaded_file($tmpVideoPath, $uploadedVideoFile)) {             
              $fvideo_path = '/upload/video/' . $actual_name.".".$extension;
              echo '&lt;li style="list-style:none"&gt;' . $fvideo_path . '&lt;/li&gt;';
  
                  $size = getimagesize($tmpImgPath);
                  $ratio = $size[0]/$size[1]; // width/height
  
                  if( $ratio &gt; 1) {
                      $width = 300;
                      $height = 300/$ratio;
                  }
                  else {
                      $width = 300*$ratio;
                      $height = 300;
                  }
                  $src = imagecreatefromstring(file_get_contents($tmpImgPath));
                  $dst = imagecreatetruecolor($width,$height);
                  imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]);
                  imagedestroy($src);
                  if(imagepng($dst,$uploadedImgFile)) {
                      $fimg_path = '/upload/video/' . $actual_name_img.".".$extension_img;
                      echo '&lt;li style="list-style:none"&gt; with Image Title of ' . $fimg_path . '&lt;/li&gt;';
                  }
                  imagedestroy($dst);
              //save to db
              save_db_video($fvideo_path, $fimg_path, $_POST['cat_value_video'], $_POST['video_title']);
          } else {
              echo '&lt;h2&gt;There was a problem saving the uploaded file&lt;/h2&gt;';
          }
  
          echo '&lt;/ul&gt;';
  
      }
  
      echo '&lt;button class="btn_back"&gt;&lt;a href="members.php"&gt;&lt;h2&gt;Back to Uploader&lt;/h2&gt;&lt;/a&gt;&lt;/button&gt;';
  </code></pre>