正如您已經提到的,許多瀏覽器都不會允許您這樣做。這是1)一件好事(安全和什麼),2)正確的答案(沒有辦法迫使他們給出完整的路徑,缺少一些利用)。對不起,你不喜歡它,但這不太可能使答案不同。
更積極的一點是,可能使用某些Flash或Java小程序訪問本地文件(例如Uploadify),但用戶需要允許其權限提升。
編輯:我查了一下GMail做了什麼,你可能想要一些與你的問題完全不同的東西:它使用巧妙的僞裝iframe
(沒有邊框,相同的背景,看起來像頁面的一部分),它包含一個小表單上傳文件。簡化:
<form id="main_mail_form">
<input type="hidden" name="compose_mail_identifier" value="id_beef-cafe">
<!-- buttons and previous form fields - subject, to, cc -->
<iframe src="attachments?for_message=id_beef-cafe">
<!-- note that we're passing ^^^^^^^^^^^^ the same identifier here -->
</iframe>
<!-- other form fields and buttons -->
</form>
的iframe中:
<form id="attachment_mail_form">
<input type="hidden" name="compose_mail_identifier" value="id_beef-cafe">
<!-- ^^ note that this has the same value as the main form -->
<input type="file">
<!-- other form elements -->
</form>
當您添加的附件的郵件,你只提交的iframe裏面的表單。 Google似乎使用一些每個消息唯一的標識符(在該示例中命名爲compose_mail_identifier
)將附件與電子郵件匹配。這樣,附件和消息就會以不同的形式處理,並且只有在您點擊「發送」時纔會合併到電子郵件中。
你的意思是你需要知道他住在哪裏? – 2010-11-22 10:08:14
你的問題是關於完整的文件路徑。但在我看來,你真的想上傳一個文件。爲此,你可以谷歌JQuery文件上傳。 – extraneon 2010-11-22 10:11:00
是的,我想要在哪裏文件住在客戶端 – 2010-11-22 10:20:11