-1

I have a select box with some urls in it (dynamic). I want to upload/copy those images to a folder (with 0777 permission). Somehow it does nothing. Not getting any errors but the images aren't being copied. Whats wrong with my code?

echo '<select name="photoselect[]" multiple="multiple"></select>';

echo '<form action="" method="post"><input type="submit" name="CopyImages"/> </form>';

$target_dir = "upload/"

if(isset($_POST['CopyImages']))

foreach ($_GET['photoselect'] as $photourl) {
    $photoname= basename($photourl);

    copy($photourl, $target_dir.'/'.$photoname);

}
Jack
  • 119
  • 1
  • 3
  • 9

1 Answers1

1

Do you form in this way:

<form action="" method="post">
    <select name="photoselect[]" multiple="multiple"></select>
    <input type="submit" name="CopyImages"/>
</form>

And your php code:

$target_dir = "upload/";

if(isset($_POST['CopyImages']))
    foreach ($_POST['photoselect'] as $photourl) {
        $photoname= basename($photourl);
        copy($photourl, $target_dir.'/'.$photoname);
    }
}
Abdullah R.
  • 106
  • 5