获得文件的文件名通过AJAX上传 [英] get filename of file uploaded through ajax

查看:205
本文介绍了获得文件的文件名通过AJAX上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单。

我写在PHP中上传类,并已决定将包括对AJAX上传的支持。

I am writing an uploader class in php and have decided to include support for ajax uploads.

使用Firefox,我发现了一个头的X文件名被发送。我使用的是第三方的上传javascript库,并把它发送一个查询字符串到PHP脚本的文件名。

Using firefox, I detected that a header X-File-Name is sent. I am using a 3rd party javascript library for the uploads, and it sends the filename in a query string to the php script.

我想知道的是什么,有没有通过X文件名获取文件名一样,与所有的Ajax请求一致或者我需要用户指定文件的名称一致的手段。

What I wish to know is, is there a consistent means of getting the filename like through the X-File-Name that is consistent with all ajax requests or I need users to specify the name of the file.

我可以要求用户指定,但我很想有一个一致的方法。

I can ask users to specify, but I would love to have a consistent method.

感谢。

推荐答案

这似乎没有具体实现XHR的世界。因此,我导致使用 X-文件名头,如果我发现它,但需要用户提交的文件名。上传从输入流中读取。

It seems nothing is concrete in the world of xhr. I therefore resulted to using the X-File-Name header if I found it but requiring a user submitted filename. Uploads are read from the input stream.

这篇关于获得文件的文件名通过AJAX上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆