title: Resize an image on upload then use the move_uploaded_file()
body: <p>Is there any way to resize the $_FILES["xfile1"]["tmp_name"] before I send it off to the move_uploaded_file() function? I checked every where but nobody seems to use this function after resizing the image.</p>
  
  <p>ADDED*</p>
  
  <pre><code>// Create image from file
     switch(strtolower($_FILES['xfile1']['type']))
     {
  case 'image/jpeg':
      $image = imagecreatefromjpeg($_FILES['xfile1']['tmp_name']);
      break;
  case 'image/png':
      $image = imagecreatefrompng($_FILES['xfile1']['tmp_name']);
      break;
  case 'image/gif':
      $image = imagecreatefromgif($_FILES['xfile1']['tmp_name']);
      break;
  default:
      exit('Unsupported type: '.$_FILES['xfile1']['type']);
  }
  
   // Delete original file
   @unlink($_FILES['image']['tmp_name']);
  
   // Target dimensions
   $max_width = 540;
   $max_height = 540;
  
   // Get current dimensions
   $old_width = imagesx($image);
   $old_height = imagesy($image);
  
  // Calculate the scaling we need to do to fit the image inside our frame
  $scale = min($max_width/$old_width, $max_height/$old_height);
  
  // Get the new dimensions
   $new_width = ceil($scale*$old_width);
   $new_height = ceil($scale*$old_height);
  
   // Create new empty image
  $new = imagecreatetruecolor($new_width, $new_height);
  
  
  // Resample old into new
  imagecopyresampled($new, $image, 
      0, 0, 0, 0, 
      $new_width, $new_height, $old_width, $old_height);
  
  
   ob_start();
   imagejpeg($new,'saved.jpeg' , 90);
   $data = ob_get_clean();
  </code></pre>
  
  <p>So i have this so far. I have this $data variable which i want to replace with $_FILES["xfile1"]["tmp_name"] in the move_uploaded_file() function. Is that possible?</p>
  
  <p>Thanks in Advance.</p>