更新时间:2023-11-26 23:06:10
好吧,终于知道了. params数组需要特殊的输入,以使用键"options_xx_file_action"告诉自定义选项如何处理文件("save_new"或"save_old").看起来像这样:
Ok finally figured this out. The params array needs special entry to tell the custom option with the key "options_xx_file_action" what to do with a file ('save_new' or 'save_old'). This would look like:
$params = array(
'product' => $productId,
'qty' => $quantity,
'options' => array(
$customOptionSize->getId() => $selectedSize,
$customOptionColor->getId() => $selectedColor,
),
'options_'.$customOptionDesign->getId().'_file_action'=>'save_new',
);
很显然,您需要将文件添加到发布请求中(通过表单或类似方式).该文件的名称应为"options_xx_file".例如,在我的情况下,我的$ _FILES看起来像:
Obviously, you will need to add the file to the post request (via form or therelike). The name of the file should be "options_xx_file". For example, in my case my $_FILES looked like:
Array (
[options_108_file] => Array
(
[name] => i-like.png
[type] => application/octet-stream
[tmp_name] => C:\xampp\tmp\phpAAB8.tmp
[error] => 0
[size] => 6369
)
)