[英]How to send the filename with Plupload?
I have been looking at this problem for quite some time now. 我已经研究这个问题已有一段时间了。
My problem is simple, i want to send the filename along with the file, as a multipart request in Plupload, but i have not been able to do it yet. 我的问题很简单,我想将文件名和文件一起发送,作为Plupload中的一个多部分请求,但是我还没有做到这一点。
I need the full filename of the uploaded file, so i can save the file with the right file extention, in this case it is images only. 我需要上传文件的完整文件名,因此我可以使用正确的文件扩展名保存文件,在这种情况下,它仅是图像。
Here is what i have until now (JavaScript part): 这是到目前为止我所拥有的(JavaScript部分):
BeforeUpload: function(up, file) {
up.settings.multipart_params = {"name" : file.name, "gallery" : "9650f952-e397-11e5-8bca-d43d7e9e4e29"}
},
And in PHP i have this piece: 在PHP中,我有这块:
if (!empty($_FILES)) {
$fileName = $_FILES["file"]["name"];
} elseif (isset($_REQUEST["name"])) {
$fileName = $_REQUEST["name"];
} else {
$fileName = uniqid("file_");
}
$filearr = explode ($fileName);
$ext = array_pop ($filearr);
$withoutext = implode ($filearr);
So, how does i fix this mess? 那么,我该如何解决这一问题呢?
I should have been paying more attention to the code. 我应该更多地关注代码。
I found 2 errors, it is both the explode and implode functions that are missing a parameter, so the answer is simply this: 我发现了2个错误,都是缺少参数的explode和implode函数,因此答案很简单:
$filearr = explode (".",$fileName);
$ext = array_pop ($filearr);
$withoutext = implode (".",$filearr);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.