将图像从url复制到文件夹出错?-PHP
我有一个选择框,里面有一些URL(动态)。我想上传/复制这些图片到一个文件夹(0777权限)。不知怎的,它什么也没做。未收到任何错误,但未复制图像。我的代码怎么了将图像从url复制到文件夹出错?-PHP,php,image,copy,Php,Image,Copy,我有一个选择框,里面有一些URL(动态)。我想上传/复制这些图片到一个文件夹(0777权限)。不知怎的,它什么也没做。未收到任何错误,但未复制图像。我的代码怎么了 echo '<select name="photoselect[]" multiple="multiple"></select>'; echo '<form action="" method="post"><input type="submit" name="CopyImages"/>
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);
}
echo';
回声';
$target_dir=“upload/”
如果(isset($_POST['CopyImages']))
foreach($\u获取['photoselect']作为$photourl){
$photoname=basename($photourl);
副本($photourl,$target_dir.'/'.$photoname);
}
您是这样形成的:
<form action="" method="post">
<select name="photoselect[]" multiple="multiple"></select>
<input type="submit" name="CopyImages"/>
</form>
你是否知道你的
选择菜单不在你的表单中
?你的表单正在提交post请求,因此将$\u GET['photoselect']
更改为$\u post['photoselect']
。同时将选择
放入表格
谢谢!100%工作:)
$target_dir = "upload/";
if(isset($_POST['CopyImages']))
foreach ($_POST['photoselect'] as $photourl) {
$photoname= basename($photourl);
copy($photourl, $target_dir.'/'.$photoname);
}
}