将图像从url复制到文件夹出错了? - PHP

时间:2017-10-27 09:36:37

标签: php image copy

我有一个选择框,里面有一些网址(动态)。我想将这些图像上传/复制到文件夹(具有0777权限)。不知怎的,它什么也没做。没有得到任何错误,但图像没有被复制。我的代码有什么问题?

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);

}

1 个答案:

答案 0 :(得分:1)

你是否以这种方式形成:

"SELECT mess_txt,mess_time,mess_to FROM (SELECT mess_to AS user_id,mess_txt,mess_time,mess_id,mess_to FROM messages WHERE mess_from = '"+data.active+"' AND mess_to='"+data.clicked+"' UNION SELECT mess_to as user_id,mess_txt,mess_time,mess_id,mess_to FROM messages WHERE mess_from = '"+data.clicked+"' AND mess_to='"+data.active+"') sq JOIN users ON users.id = sq.user_id ORDER BY mess_time ASC"

你的php代码:

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