0
我試圖同時移動一個表單中的五個不同的文件,但只有一個圖像移動。我的數據庫表中每個文件名有五列。上傳的圖像名稱保存在數據庫列中,但唯一的問題是僅移動一個文件而不是所有上傳的文件。以下是代碼:move_uploaded_file兩個或多個不同的圖像名稱只移動一個
//form isValid...
$post = $form2->getData();
$imageonetmp = $post["imageone"]["tmp_name"];
$imageonename = $post["imageone"]["name"];
$imagetwotmp = $post["imagetwo"]["tmp_name"];
$imagetwoname = $post["imagetwo"]["name"];
$imagethreetmp = $post["imagethree"]["tmp_name"];
$imagethreename = $post["imagethree"]["name"];
$imagefourtmp = $post["imagefour"]["tmp_name"];
$imagefourname = $post["imagefour"]["name"];
$imagefivetmp = $post["imagefive"]["tmp_name"];
$imagefivename = $post["imagefive"]["name"];
$filepath = $this->_dir.$imageonename;
$filepath = $this->_dir.$imagetwoname;
$filepath = $this->_dir.$imagethreename;
$filepath = $this->_dir.$imagefourname;
$filepath = $this->_dir.$imagefivename;
move_uploaded_file($imageonetmp, $filepath);
move_uploaded_file($imagetwotmp, $filepath);
move_uploaded_file($imagethreetmp, $filepath);
move_uploaded_file($imagefourtmp, $filepath);
move_uploaded_file ($imagefivetmp, $filepath);
/*set image names to db here*/
$entityManager->persist($autos);
$entityManager->flush();
希望有人可以提供幫助。
非常感謝。它現在有效 – dino