在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/PHP  網(wǎng)絡安全/ php 上傳一張照片 到兩個路徑?

php 上傳一張照片 到兩個路徑?

$target_dir = "a1/";
  $target_file = $target_dir . basename($_FILES["myFile_cover"]["name"]);
  $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  $imagename = $addfirstROW['id'] . '.' . $imageFileType;
  $destination = $target_dir . $imagename;
  $destination2 = "a2/" . $imagename;
move_uploaded_file($_FILES["myFile_cover"]["tmp_name"], $destination);
  move_uploaded_file($_FILES["myFile_cover"]["tmp_name"], $destination2);

我想同一照片上傳到不同的路徑...
一個是a1一個是a2
都是同一張照片
這要怎麼做?就是變兩張的意思

上傳照片後我會先把圖片壓縮,再存到a1,但我想有個原始檔(未壓縮的)先到a2備份

回答
編輯回答
短嘆

copy

2017年2月6日 18:44
編輯回答
雨蝶

你第一次用move_uploaded_file之后,臨時文件就不存在了,第二次就不能再執(zhí)行了。

第一次移動后,第二個路徑可以從第一個路徑獲取。

move_uploaded_file($_FILES["myFile_cover"]["tmp_name"], $destination);
file_put_contents($destination2,file_get_contents($destination));
2017年10月26日 19:25