开发者

get filename of file uploaded through ajax

开发者 https://www.devze.com 2023-03-04 13:46 出处:网络
My problem is quite simple. I am writing an uploader class in php and have decided to include support for ajax uploads.

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.开发者_StackOverflow

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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消