如何将JS控制台日志信息传递给PHP变量?

问题描述 投票:0回答:1

如何将下面脚本中的“ result.info.path”传递给全局PHP $ _POST变量?

var myWidget = cloudinary.createUploadWidget({
  cloudName: 'my_folder', 
  uploadPreset: 'preset_unsigned'}, (error, result) => { 
    if (!error && result && result.event === "success") { 
      console.log('Done! Here is the image info: ', result.info.path); 

    }
  }
)
javascript php global-variables console.log
1个回答
0
投票

无法通过这种方式将内容传递给php变量。因为Javascript是在php执行代码并响应浏览器之后运行的。此处php是后端/服务器端,而javascript是前端/客户端语言。因此,您需要使用AJAX将内容从客户端传递到服务器。

© www.soinside.com 2019 - 2024. All rights reserved.