class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
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 )
I need the images to follow this naming convention: image_1.JPG | image_2.JPG | image_3.JPG | image_4.JPG | image_5.JPG
If i set the $handle->file_new_name_body = 'image'; the first image is called image.jpg then, the second image is image_1.jpg and so on...
Can someone please advise how I might be able to do this?
For instance:
the resulting images are:
image_5.JPG
image_5_1.JPG
image_5_2.JPG
image_5_3.JPG
image_5_4.JPG
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!
I defined a variable:
then modified the handle:
and made sure the following two handles were set:
Hopefully this will help someone out there trying to do the same.
Thanks again for a fantastic class!
Glad you like the class :)