php - 如何在 smarty 框架 (*.tpl) 中将图像发送到服务器?我已经写好了预览图片代码,但是我不知道怎么发送
问题描述
如何在 smarty 框架 (*.tpl) 中将图像发送到服务器?我已经编写了预览图像代码,但我不知道如何发送它。
这是 *.tpl 代码
function image_show(){
var image = "";
//images.forEach((i) => {
//console.log(i);
//})
images.forEach((i) =>{
image += `<div><img src="`+i.url+`"><span onclick="delete_image(`+images.indexOf(i)+`)">×</span></div>`;
})
return image;
}
function delete_image(e){
images.splice(e,1);
document.getElementById('container').innerHTML = image_show();
}
function check_duplicate(name){
var image = true;
if(images.length >0){
for(e=0; e<images.length; e++){
if(images[e].name == name){
image = false;
break;
}
}
}
return image;
}
<form action="#" method="post" id="form">
<div>
<input type="file" id="image" name="Image" multiple="" onchange="image_select()">
<button type="button" onclick="document.getElementById('image').click()">Choose Images</button>
</div>
<div id="container"></div>
</form>
当用户选择图像时,它可以预览图像,但如何上传到服务器?
在php中,我可以使用这种方法
<form action="upload.php" method="post" enctype="multipart/form-data">
但是,在 smarty framewodk 中我可以使用哪种方法呢?
这是聪明的代码
$this->context->smarty->assign([
'PGWD' => $_SERVER['QUERY_STRING'],
'application_page' => $application_page,
'application_process' => $application_process,
'js' =>$js,
]);
那么,我是使用 ajax 方法还是其他类似的功能?
解决方案
推荐阅读
- javascript - 无法使用组合减速器 REACT 显示数据
- python - Matplotlib 渲染条形图不正确
- r - 在 ggduo 散点图矩阵中显示相关指数(带着色)
- javascript - 如何使用 jQuery 自动完成功能读取 ALT 代码
- flutter - 如何更改底部导航栏的颜色?
- php - Python 关于 PHP 导入的烦恼
- amcharts - 使用 AmCharts 将单个表格导出为 PDF
- python - Python中Pandas数据框中每个子组的订单号
- c# - 如何在 C# 中使用反序列化过滤 xml?
- python - 从 Python 2 环境打开 Spyder 仍然在 Spyder 中运行 Python 3