Prestashop 在发送消息时上传文件 [英] Prestashop uploading file while sending message

查看:45
本文介绍了Prestashop 在发送消息时上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在订单详细信息页面中添加附加文件的功能.有一个消息发送表单,我正在尝试在其中实现文件上传.

我已将此添加到 order-detail.tpl

<input type="file" name="fileUpload" id="msgfile" class="inputfile"/><label for="msgfile"><i class="icon-cloud-upload"></i>{l s='Prisegti failą'}</label><p id="nbchars"></p>

和 OrderDetailController.php 的值

if (Tools::isSubmit('submitMessage')) {$extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif','.jpg');$file_attachment = Tools::fileAttachment('fileUpload');如果 (!count($this->errors)) {...if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_.basename($file_attachment['rename)']))){$cm->file_name = $file_attachment['rename'];@chmod(_PS_UPLOAD_DIR_.basename($file_attachment['rename']), 0664);}...}}

我从 ContactController.php 复制它,它运行良好,但在这里它没有.有人知道我做错了什么吗?

解决方案

所以我最终找到了解决方案.我需要编辑 history.js

data: new FormData(this),

然后它上传文件.否则 $_FILES[] 被处理为空.

现在一切正常.

I am trying to add function to attach file in order details page. There is an message sending form and i am trying to implement file upload in there.

I have added this to order-detail.tpl

<div class="form-group">
    <input type="file" name="fileUpload" id="msgfile" class="inputfile" />
    <label for="msgfile"><i class="icon-cloud-upload"></i> {l s='Prisegti failą'}</label>
    <p id="nbchars"></p>
</div>

and values to OrderDetailController.php

if (Tools::isSubmit('submitMessage')) {
    $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
    $file_attachment = Tools::fileAttachment('fileUpload');
  if (!count($this->errors)) {
  ...
    if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_.basename($file_attachment['rename']))) {
        $cm->file_name = $file_attachment['rename'];
        @chmod(_PS_UPLOAD_DIR_.basename($file_attachment['rename']), 0664);
    }
  ...
  }
}

I copied it from ContactController.php which works perfectly, however in here it does not. Anyone have idea what am i doing wrong?

解决方案

SO i eventually found how to make it. I needed to edit history.js

data: new FormData(this),

Then it uploads files. Otherwise $_FILES[] are processed empty.

Now it works fine.

这篇关于Prestashop 在发送消息时上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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