Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amp html 在上传之前,AMP中是否有显示输入表单中所选图像的方法?_Amp Html_Amp Bind_Amp Img - Fatal编程技术网

Amp html 在上传之前,AMP中是否有显示输入表单中所选图像的方法?

Amp html 在上传之前,AMP中是否有显示输入表单中所选图像的方法?,amp-html,amp-bind,amp-img,Amp Html,Amp Bind,Amp Img,我想在使用AMP(在客户端)上传之前显示输入表单文件中的图像,我试图避免将图像上传到临时文件夹并从那里加载的过程。此表单用于将项目(带有图像)添加到列表中,很容易放弃,因此我希望避免清除孤立图像 我做了一些研究,发现所有的解决方案都涉及Javascript,比如和,但我不喜欢在“完整的网站”中使用Javascript 是否有使用AMP解决此问题的解决方案?目前AMP不支持此解决方案。一种解决方法是通过iframe嵌入表单,并使用JS在其中实现文件选择器。我解决了此问题。我在页面中看到允许base

我想在使用AMP(在客户端)上传之前显示输入表单文件中的图像,我试图避免将图像上传到临时文件夹并从那里加载的过程。此表单用于将项目(带有图像)添加到列表中,很容易放弃,因此我希望避免清除孤立图像

我做了一些研究,发现所有的解决方案都涉及Javascript,比如和,但我不喜欢在“完整的网站”中使用Javascript


是否有使用AMP解决此问题的解决方案?

目前AMP不支持此解决方案。一种解决方法是通过iframe嵌入表单,并使用JS在其中实现文件选择器。

我解决了此问题。我在页面中看到允许base64作为src值,因此我实现了从表单接收图像并返回此数据的和端点:

data:{content_type};base64,{coded_img}
然后我使用on属性设置该数据的状态,图像的src属性获取该值

<form id="item-form"
      method="post"
      action-xhr="//{{ request.get_host }}{% url 'submit-image' %}"
      target="_top"
      on="submit-success:AMP.setState({ currentItem: {imageUrl: event.response.image }})">
<input type='file' name='image'>
<button type='submit'></button></form>

<amp-img alt="Item Image"
         src=""
         [src]="currentItem['imageUrl']"
         width="150"
         height="150"
         layout="responsive">
</amp-img>