-1

我想知道如何添加到这行代码以将图像上传到photos/,以及/mobile/photos?那么我将如何添加/mobile/photos到脚本中呢?

$place_file = move_uploaded_file( 
    $_FILES['fileField']['tmp_name'], 
    "photos/".$newname);
4

4 回答 4

1
if (move_uploaded_file($_FILES['fileField']['tmp_name'], "photos/$newname")) {
    copy("photos/$newname", "mobile/photos/$newname");
}
于 2013-01-13T08:20:03.357 回答
0

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
}
于 2013-01-13T08:25:48.417 回答
0

您可以先将_uploaded_file 移动到第二个文件夹,然后再复制到第二个文件夹,例如:

if( move_uploaded_file( $_FILES['fileField']['tmp_name'], "photos/".$newname) ) {
   //copy to mobile/photos
   copy("photos/".$newname, "mobile/photos/".$newname);
}
于 2013-01-13T08:19:55.480 回答
0

您可以使用 php复制文件:

copy("photos/$newname", "mobile/photos/$newname");
于 2013-01-13T08:21:19.377 回答