Possible Duplicate:
Clone + Rename file with PHP
This should be pretty easy. I wan't to copy & rename images that already exist on the server while still retaining the original image.
Here's the original image location:
images/ folder/ one.jpg
This is what I want:
images/ folder/ one.jpg one_thumb.jpg
How can I achieve this? You can see I'm not just simply renaming an existing file / image. I want to copy it and rename it to the same directory.
1 : an imitation, transcript, or reproduction of an original work (such as a letter, a painting, a table, or a dress) 2 : one of a series of especially mechanical reproductions of an original impression also : an individual example of such a reproduction. 3 archaic : something to be imitated : model.
First developed by Larry Tesler, copy and paste or copy is the act of duplicating text, data, files, or disks, producing two or more of the same file or segments of data. Copying a file to an alternate location, such as a USB jump drive, is a common procedure for backing up or sharing a file.
verb (used with object), cop·ied, cop·y·ing. to make a copy of; transcribe; reproduce: to copy a set of figures from a book. to receive and understand (a radio message or its sender). to follow as a pattern or model; imitate.
Just use the copy method: http://php.net/manual/en/function.copy.php
Ex:
<?php $file = 'images/folder/one.jpg'; $newfile = 'Images/folder/one_thumb.jpg'; if (!copy($file, $newfile)) { echo "failed to copy"; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With