2013-11-21 45 views
0

我正在嘗試構建類似於Google驅動器的在線存儲網站。我的代碼可以上傳文件並將其保存在特定的指定路徑中。它也有創建文件的代碼。唯一缺少的是向用戶顯示他/她在特定路徑中上傳的「多少」或「哪些」文件。顯示網頁中文件夾的內容

如Google驅動器映像(在下面的鏈接中)所示,我希望我的代碼看起來像這樣,我希望我的用戶能夠看到他/她在網頁上以串行方式上傳文件。我不知道該怎麼做,或者是否可以在PHP中使用,或者如果可能的話,在PHP中使用哪個函數。我也不確定Google搜索中的「輸入什麼內容」以查找這種類型的編碼的一些示例。請告訴我任何能夠幫助我開始我的項目的這一部分的任何事情。

http://www.google.com.bd/imgres?sa=X&biw=1024&bih=605&tbm=isch&tbnid=kSX8G1DGHuYiHM:&imgrefurl=http://www.zdnet.com/blog/networking/free-storage-for-you-google-drive-to-arrive-today/2293&docid=VGLnSQuNf4vGLM&imgurl=http://www.zdnet.com/i/story/62/58/002293/google-drive.png&w=1012&h=725&ei=JPCNUtj_FoKtrAfYkoHwCA&zoom=1&ved=1t:3588,r:12,s:0,i:122&iact=rc&page=2&tbnh=173&tbnw=241&start=8&ndsp=14&tx=182&ty=107

(我還是脫機工作。我還沒有推出它的在線)
如果你從我現有的工作需要的任何代碼,請告訴我。我很想上傳我的代碼。

---謝謝。

+0

是,拯救磁盤上的文件或您存儲在一個數據庫的名字呢? –

+0

這些文件直接保存在我的電腦的硬盤上。在這裏,C:\ abcd \ sss – user3017315

回答

0

因此,您可以在上傳(保存/移動文件)時在數據庫中插入記錄。

而且例如僞代碼,因爲你沒有提供任何將是:

if (checkForErrors()) { 
    // your error page for file exists, improper extension, and other violated constraints 
} else { 
    move_uploaded_file($_FILES['file']['tmp_name'], 'your/path/here/' . $_FILES['file']['name']); 
    $db->query("INSERT INTO uploads (uploader, filename, uploaded_on) VALUES ('{$_SESSION['username']}', '{$_FILES['file']['name']}', NOW());"); 
} 
// later you can just fetch the results for the current uploaded 
$db->query("SELECT filename, uploaded_on FROM uploads WHERE uploader = '{$_SESSION['username']}';"); 
// under the row of filename will be stored the files that the current user has uploaded 
+0

好主意!!!讓我們看看它是否正常工作... – user3017315

相關問題