我想知道如何添加到这行代码以将图像上传到photos/
,以及/mobile/photos
?那么我将如何添加/mobile/photos
到脚本中呢?
$place_file = move_uploaded_file(
$_FILES['fileField']['tmp_name'],
"photos/".$newname);
我想知道如何添加到这行代码以将图像上传到photos/
,以及/mobile/photos
?那么我将如何添加/mobile/photos
到脚本中呢?
$place_file = move_uploaded_file(
$_FILES['fileField']['tmp_name'],
"photos/".$newname);
if (move_uploaded_file($_FILES['fileField']['tmp_name'], "photos/$newname")) {
copy("photos/$newname", "mobile/photos/$newname");
}
Its simple just use the copy PHP function. But first confirm that file exist before attempting to copy because copying might fail based a number of reasons
Here is a sample code:
if ($success = move_uploaded_file($_FILES['fileField']['tmp_name'],
"photos/$newname") )
{
copy("photos/$newname", "mobile/photos/$newname");
}else{
// error occurred
}
您可以先将_uploaded_file 移动到第二个文件夹,然后再复制到第二个文件夹,例如:
if( move_uploaded_file( $_FILES['fileField']['tmp_name'], "photos/".$newname) ) {
//copy to mobile/photos
copy("photos/".$newname, "mobile/photos/".$newname);
}
您可以使用 php复制文件:
copy("photos/$newname", "mobile/photos/$newname");