我想知道如何添加这行代码以将图像上传到photos/
和/mobile/photos
?那么如何将/mobile/photos
添加到脚本中呢?
$place_file = move_uploaded_file(
$_FILES['fileField']['tmp_name'],
"photos/".$newname);
答案 0 :(得分:1)
if (move_uploaded_file($_FILES['fileField']['tmp_name'], "photos/$newname")) {
copy("photos/$newname", "mobile/photos/$newname");
}
答案 1 :(得分:0)
你可以move_uploaded_file然后再copy到第二个文件夹,如:
if( move_uploaded_file( $_FILES['fileField']['tmp_name'], "photos/".$newname) ) {
//copy to mobile/photos
copy("photos/".$newname, "mobile/photos/".$newname);
}
答案 2 :(得分:0)
您可以使用php {/ 3> copy该文件
copy("photos/$newname", "mobile/photos/$newname");
答案 3 :(得分:0)
它的简单使用copy PHP函数。但首先在尝试复制之前确认该文件存在,因为复制可能由于多种原因而失败
以下是示例代码:
if ($success = move_uploaded_file($_FILES['fileField']['tmp_name'],
"photos/$newname") )
{
copy("photos/$newname", "mobile/photos/$newname");
}else{
// error occurred
}