2013-03-18 88 views
-2

從文件夾移動文件到另一個我使用此代碼:檢索文件名中的變量

$new_file = new File($file['destination']->getPath() . File::SEPARATOR . $file['file']->getName()); 

現在,我需要添加一個唯一的ID,並存儲在數據庫中的文件名。 OK了uniqid():在這樣的文件名

$new_file = new File($file['destination']->getPath() . File::SEPARATOR . uniqid() . '---' . $file['file']->getName()); 

結果: 514685b08e6db --- SL004321_7_03-2013.pdf

現在,如何在一個變量來存儲這些MySQL的檢索文件名?

+0

這是非常不清楚你問這裏有什麼,你能澄清你的問題是什麼? – 2013-03-18 03:45:13

回答

0

你coud它存儲在一個變量和使用,就像

$filename = uniqid() . '---' . $file['file']->getName(); //your filename 
$new_file = new File($file['destination']->getPath() . File::SEPARATOR . $filename); 
+0

謝謝Sudhir,工作完美。 – user2123738 2013-03-18 03:53:31