get filename of file uploaded through ajax

青春壹個敷衍的年華 提交于 2019-12-11 03:39:50

问题


My problem is quite simple.

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

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.

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.

Thanks.


回答1:


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.




回答2:


I believe $_FILES[inputname][name] is what you're looking for, where inputname is the name given to the file upload input box.

http://php.net/manual/en/reserved.variables.files.php



来源:https://stackoverflow.com/questions/5921843/get-filename-of-file-uploaded-through-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!