How to transfer uploaded image to a directory as well as copy it to another directory

Viewed 29

on my project folder there is images/committee/images.jpg . This where the uploaded images are moving to

if(move_uploaded_file($image_temp,"images/committee/".$new_image_name))

Now what m trying to achieve is that.. On the Project folder there is a folder names as

user/images/committee/target.jpg this where i want to copy the image to.

copy("images/committee/".$new_image_name, "user/images/committee/".$new_image_name);

i tried using this.. but i think m giving wrong path. can some one help

1 Answers

if you use absolute paths you should be OK. ie: copy( __DIR__ . "/images/committee/".$new_image_name, __DIR__ . "/user/images/committee/".$new_image_name ); This worked for me. Do remember to check if you are in right directory if it is not working.

Related