0

I'm sure there is a pretty straight forward answer to this but I am new to PHP and can't find an answer I can get to work. Basically I have a PHP form with a file upload which needs to send images to two folders. The current code that tells the images where to be stored is as follows:

$savepath = JPATH_SITE.DS.'images'.DS.'site'.DS.'cache';

Then after the image is uploaded:

$handle->Process($savepath);

Is there an easy way of also copying the file to another folder as part of the upload process?

Thanks in advance!

1
  • 2
    Yes, use copy() Commented Sep 7, 2012 at 1:24

1 Answer 1

3
$file = "/path/to/orig/file";
$newfile = "/path/to/dest/file";
copy($file, $newfile);

Repeat the copy() command as many times as necessary to copy to multiple directories.

Good luck!

Sign up to request clarification or add additional context in comments.

6 Comments

You need to set the permissions. Try chmod -R 777 /path/to/directory/youre/saving/to and rerun.
I'm pretty sure the permissions are fine because if I change the $savepath to the path I want to ultimately use for $newfile (in the examples mentioned above) it sends the image to the correct folder, but then obviously doesn't send it to original $savepath folder. Perhaps I'm running this code in the wrong place...
Once the form submits I get an error saying "Empty message body..." even though all form fields are filled out correctly.
Well t\hat sounds like an error related to something you have not posted in your original question. PHP does not give that error, normally.
Sorry, I'm building a Joomla site and this PHP form is part of a component. The PHP form appears to be working (aside from that error) as long as I don't try to save to multiple folders. The only other issue is the form is supposed to email its contents to an administrator and this is not currently working. You are right, perhaps it is a component error rather than a general PHP error...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.