php/ajax文件上传过程?

发布于 2024-10-12 04:49:17 字数 532 浏览 3 评论 0原文

我想知道处理这个过程的最佳工作流程是什么。

基本步骤是。

用户选择一个 csv 文件并上传。
然后根据一组规则检查 csv 文件。

如果 csv 文件无效 用户会看到无效的行。
用户可以选择终止上传或删除无效行。

如果 csv 文件有效,或者单击了 strip 用户将看到一个屏幕来选择文件名。

如果文件名已被使用,用户可以选择
a) 重命名文件(为其选择的名称)
b) 替换现有文件。
c) 将文件重命名为 filename_1 等

选择名称后,将在数据库中创建一个名为 (csv_filename) 的表;
然后将 csv 中的数据输入到表中。
文件已删除。
用户被带到显示文件数据的页面(来自表格)


我的问题是, 这一切都是通过ajax来完成的。 我如何处理报告我们正在处理的文件?

我不想在 ajax 响应中传回文件名,因为这太容易篡改。

我不想创建一个表来保存文件路径并传回 id,因为仅仅为此创建一个表似乎是一种浪费。

I am wondering what the best workflow would be to handle this process.

Basic steps are.

The user selects a csv file and uploads it.
The csv file is then checked against a set of rules.

If the csv file is invalid
The user is shown the rows that are invalid.
The user is given the choice to terminate the upload or, strip the invalid lines.

If the csv file is valid, or strip is clicked
The user is shown a screen to choose the filename.

If the filename is already taken the user is given the choice to
a) rename the file (to a name of their choosing)
b) replace existing file.
c) rename the file to filename_1 etc

When the name is chosen a table is created in the database called (csv_filename);
Then data from the csv is entered into the table.
The file is deleted.
The user is taken to a page showing the file data (from the table)


My issue is,
This is all run through ajax.
How do I handle reporting what file we are dealing with?

I dont want to pass back the filename in an ajax response as that is too easy to tamper with.

I dont want to create a table to hold the filepath and pass back an id, as it seems to be a waste to have a table for just this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉世弥音 2024-10-19 04:49:17

在第一步上传文件时,存在一些问题。它完成了,它有一个文件名,并且无法终止,因为它已经在那里了。一定是这样,否则你将如何分析它?

从用户的角度来看,您可以让它看起来就像它的工作方式一样,这可能就是您的意思。

无论如何,要报告您正在处理的文件,请将其存储在会话变量中。

There are some issues with this, when the file is uploaded in the first step. Its done, its got a file name, and it can't be terminated because its already there. It has to be, or how will you analyze it?

From the users perspective you can make it look like thats how its working, which maybe is what you meant.

Anyways, to report what file you're dealing with, store it in a session variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文