Force image renaming to start at 1 and increment

See all posts See thread Reply

Re: Force image renaming to start at 1 and increment new!
by Jason, 17 years ago
I thought i'd elaborate on my first post to make it easier to understand what i'm trying to achieve...

The five images are passed from a form as an array to upload.php.
$files = array();
foreach ($_FILES['image'] as $k => $l) {
  foreach ($l as $i => $v) {
    if (!array_key_exists($i, $files)) 
      $files[$i] = array();
    $files[$i][$k] = $v;
  }
}
foreach ($files as $file) {
  $handle = new Upload($file);
  if ($handle->uploaded) {
    $handle->file_new_name_body = 'image';
    $handle->file_overwrite = true;
    $handle->file_auto_rename = false;
    $handle->file_new_name_ext = 'JPG';
    $handle->image_resize = true;
    $handle->image_x = 280;
    $handle->image_ratio_y = true;
    $handle->jpeg_quality = 60;
  }
}
The form is submitted and the images need to be resized & renamed to image_1.JPG => image_5.JPG and need to overwrite the existing 5 images in the destination directory... (which are also named image_1.JPG => image_5.JPG )

Hope this clarifies what i'm trying to achieve.

Thanks in advance!Reply