node.js - 为什么 {"files":[]} show up when try to run blueimp uploader?

标签 node.js file-upload jquery-file-upload blueimp

我已遵循以下指示:

You can install Node.js sample to your server via npm. npm install blueimp-file-upload-node

Start service: ./node_modules/blueimp-file-upload-node/server.js

Download plugin, unzip it, edit index.html and point form action to your Node.js (i.e. to http://localhost:8080). You can also upload project files to any other server and use it as a UI to upload files to Node.js server.

当我导航到本地主机 8888 时,我得到一个文件数组:{"files":[]}。本地主机 8080 无法连接。

这是索引页上的表单操作:

    <form id="fileupload" action="//localhost:8888" method="POST" enctype="multipart/form-data">

我是 Node 和应用程序开发的新手。任何帮助将非常感激。谢谢。

最佳答案

查看该模块中的代码,默认端口为 8888,因此请使用 localhost:8888 作为服务。

导航到localhost:8888将返回迄今为止已上传的文件列表。在你的情况下,这个目录是空的,最初对我来说也是空的。

您可以手动将文件放入上传目录中进行测试 - 我是这样做的:

touch node_modules/blueimp-file-upload-node/public/files/test.txt

然后当访问localhost:8888时我得到:

{"files":[{"name":"test.txt","size":0,"deleteType":"DELETE","deleteUrl":"http://localhost:8888/files/test.txt","url":"http://localhost:8888/files/test.txt"}]}

这是个好消息!要实际发布文件,您将需要比您给出的示例更多的内容。

在我使用的sample.html中(取自here)

<form enctype="multipart/form-data" action="http://localhost:8888/upload" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    <label for="upload-file">Choose a file to upload:</label>
    <input name="uploadfile" id="upload-file" type="file" /><br />
    <input type="submit" value="Upload File" />
</form>

使用该表单选择并上传文件使其可用。

关于node.js - 为什么 {"files":[]} show up when try to run blueimp uploader?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19282290/

相关文章:

node.js - nodejs中用于测试和开发的不同环境变量

javascript - 如何从Django浏览本地文件并存储文件信息

node.js - 在 Nodejs Express 4 中通过单个输入上传多个文件的最佳方法是什么?

ajax - 发生管道损坏时如何处理 AJAX 响应?

jquery - 如何在 bootstrap-fileinput 插件中显示进度?

javascript - 关键字 "this"进入eventHandler函数,运行到类中

javascript - 如何防止 Node 程序停止运行?

php - 向通过 PHP 上传的文件添加时间戳和自定义名称

php - 使用 cURL 上传多个文件

node.js - 从 Amazon S3 存储桶检索图像