Upload class - save file twice

Any problems relating to the premium downloads should go in here
Post Reply
sinan
Posts: 1
Joined: Mon Jul 16, 2012 11:26 am

Upload class - save file twice

Post 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?
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Upload class - save file twice

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Upload class - save file twice

Post 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]
Image
Post Reply