-2

I have images with checkboxes in my website. When the user selects a few images, I have to move that from one directory to another. How do I move selected image files from one directory to another directory using Php?

Ben Rhys-Lewis
  • 3,118
  • 8
  • 34
  • 45
  • google-senpai may be acting up when it comes to showing images as of late but can still search for [php move file](https://www.google.com.au/search?q=php+move+file&oq=php+move+file) – Memor-X Sep 23 '16 at 03:04
  • Possible duplicate of [PHP - Move a file into a different folder on the server](http://stackoverflow.com/questions/19139434/php-move-a-file-into-a-different-folder-on-the-server). – showdev Sep 26 '16 at 17:43

1 Answers1

0

docs move_uploaded_file

$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_FILES["pictures"]["name"][$key];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
G San
  • 81
  • 6