我想讓我的網站上的用戶上傳圖片。 我一直在使用Formspree(https://formspree.io/) 我收到圖像的名稱,但沒有附加到電子郵件的圖像。用formspree上傳文件
我使用:
<label>
Upload Photo
<input type="file" name="uploadField" />
</label>
有沒有人能夠做到這一點?
我想讓我的網站上的用戶上傳圖片。 我一直在使用Formspree(https://formspree.io/) 我收到圖像的名稱,但沒有附加到電子郵件的圖像。用formspree上傳文件
我使用:
<label>
Upload Photo
<input type="file" name="uploadField" />
</label>
有沒有人能夠做到這一點?
感謝斯科特 - 我接觸Formspree並得到了我的答案 - 想我會分享它其他誰有同樣的問題。
Formspree想在將來支持文件上傳,但還沒有得到它的工作。
在此期間,我已經轉移到使用Simpleform,它支持上傳。
我很確定問題在於您的enctype
未定義。下面是一個使用基本的HTML表單的例子(你需要一些PHP /服務器端代碼來處理文件):
<form action="your_script.php" method="post" enctype="multipart/form-data">
Image: <input type="file" name="uploadField" />
<input type="submit" value="Submit">
</form>
Fromspree不支持文件上傳。
Formspree目前不支持文件輸入,但Formsprees FAQ有這樣的建議:
對於幾乎爲零的工作和廉價(或免費)的價格可以整合外部文件上傳服務爲Formspree形式。 Uploadcare就是一個例子。如果你只是創建一個帳戶,包括他們的小工具:
<!-- The best place for this one is your <HEAD> tag -->
<script>UPLOADCARE_PUBLIC_KEY = "demopublickey";</script>
<script
src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"
charset="utf-8"></script>
<!-- This is where the widget will be. Don't forget the name attribute! -->
<input type="hidden" role="uploadcare-uploader" name="my_file" />
每their documentation,您可以使用該Formspree形式內,收到文件的URL您的電子郵件地址。
來源:https://help.formspree.io/articles/6199-how-to-do-file-uploads-with-formspree
謝謝@Dmitry,非常感謝! – sandstrom
感謝我沒有定義的加密類型,但似乎並沒有解決這個問題的答覆斯科特 。 Formspree不需要任何PHP處理 - 如果我不能通過這種方式工作,可能不得不這樣做。 – nzdavo
如果您正在上傳文件,則需要enctype。如果formspree不需要腳本,則只需從上面的示例中刪除操作值。如果這不起作用,可能最好聯繫Formspree – ScottMcGready