Page 1 of 1

Upload class - save file twice

Posted: Mon Jul 16, 2012 11:30 am
by sinan
Hi,

I am using your upload class, I want to save the uploaded image twice.
1. Original size
2. Rezied size

However, when I save the file once, it will get deleted from the tmp, so it is not possible anymore to save it also as resized.

Original save: $upload->save_to('./uploads/' . $mdc . $upload->name);
Resized save: $upload->save_image_resized('./uploads/r_' . $mdc . $upload->name, 400);

The resized save will fail because the tmp file has been removed while saving the original.

Can you help with this?

Re: Upload class - save file twice

Posted: Mon Jul 16, 2012 3:08 pm
by Temor
I'm just brainstorming here but wouldn't it be possible to duplicate the tmp file?
[syntax=php]$original_tmp = $_FILES['file']['tmp_name']
$resize_tmp = $_FILES['file']['tmp_name'][/syntax]
and then just use the respective clone?

/Edit; I have no idea, this might not work.

Re: Upload class - save file twice

Posted: Mon Jul 16, 2012 11:16 pm
by jacek
I replied to the comment, but for the same of completeness...

save_image_resized() has an option to save the full size image as well as the resized one, so you could do

[syntax=php]$upload->save_image_resized('./uploads/r_' . $mdc . $upload->name, 400, 0, './uploads/' . $mdc . $upload->name);[/syntax]