将离线存储的表单
我对此进行了大量研究,但找不到完全适合我需求的解决方案。我正在尝试找到一种方法来创建一个简单的 html 表单(电子邮件注册表单),该表单可以离线存储数据,可能使用 html5 localStorage。我一直在研究这个解决方案: http://miniapps.co.uk/blog/post/using-html5-localstorage-as-a-fallback-for-offline-form-submission,但我不知道如何使这个工作有效作为不存储在在线服务器上的独立 html 文档。有什么建议吗?
I've been doing a fair amount of research on this, and can't find a solution that quite fits my needs. I'm trying to find a way to have a simple html form (an email sign-up sheet) that will store the data offline, possibly with html5 localStorage. I've been looking at this solution: http://miniapps.co.uk/blog/post/using-html5-localstorage-as-a-fallback-for-offline-form-submission, but I'm not sure how to make this work as a stand-alone html doc that isn't stored on an online server. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我不会为你发布一堆代码,但我会给你一个解决方案。
第一个问题是让远程服务器将文件保存在您自己的本地计算机上。这可以通过设置 FTP 服务器(需要在线连接)、创建 FTP 客户端帐户并使用您正在使用的任何服务器后端语言(PHP、C# 等)访问它来解决。
我喜欢 FileZilla服务器:http://filezilla-project.org/
在本地计算机离线的情况下,您可以设置您的服务器将信息保存到数据库中,然后“重试”连接到计算机的 ftp 服务器,直到成功。这可以在 Linux 环境中使用 CRON 作业来完成。涉及的步骤如下:
如果您的 IP 地址发生变化,您可以注册一个免费的动态 DNS 帐户,该帐户将为您提供永久地址。这是一个流行的问题:http://dyn.com/dns/
第二个问题 正在将此表单数据放入 Excel 文件中。值得庆幸的是,已经有为此目的创建的开源库,例如 PHP-Excel它将数据库表或 php 二维数组转换为 Excel 文件。
当您的用户完成表单后,它可以创建此 Excel 文件,将其放入目录中,并将路径保存到数据库中,您的 CRON 作业或 Windows 任务计划程序将在该数据库中执行脚本以通过 FTP 将该文件保存到本地计算机上。
Ok, I'm not going to post a bunch of code for you, but I will give you a solution.
The first problem is having a remote server save a file on your own local computer. This can be solved by setting up an FTP server (which will require an online connection), creating an FTP client account, and accessing it using whatever server back-end language you're using (PHP, C#, etc.)
I like FileZilla server: http://filezilla-project.org/
In the cases when your local computer is offline, you can set your server to save the information to a database, and 'retry' connecting to your computer's ftp server until it's successful. This can be done using CRON jobs in a linux environment. The steps involved would be like:
In the cases where your IP address changes, you can sign up for a free dynamic dns account that will give you a permenant address. Here's a popular one: http://dyn.com/dns/
The second problem is getting this form data into an Excel file. Thankfully, there have been open-source libraries created for this purpose such as PHP-Excel that will convert a database table or a php 2-dimensional array into an excel file.
When your user completes the form, it can create this excel file, put it in a directory, and save the path into the database where your CRON job or Windows Task Scheduler will execute a script to save that file on your local computer via FTP.