【发布时间】:2015-09-10 13:10:04
【问题描述】:
我需要将图片上传到两个不同的文件夹 有我的代码 在第一个文件夹上它正在移动 但是在第二个文件夹上它会生成无法移动第二个文件的异常
$target_path = "uploads/";
$target_path = $target_path . basename($_FILES['image']['name']);
$target_path1 = "thumbnails/";
$target_path1 = $target_path1 . basename($_FILES['image']['name']);
try {
//throw exception if can't move the file
if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
throw new Exception('Could not move file');
}
if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path1))
{
throw new Exception('Could not move 2nd file');
}
【问题讨论】:
标签: php file-upload image-upload