Safari 和文件上传表单不起作用

safari and fileupload form doesnt work

本文关键字:表单 不起作用 文件 Safari      更新时间:2023-09-26

我正在尝试为我的 typo3 扩展名添加附件上传,并且由于正常的文件输入不适用于设计。我决定添加一个文本输入,以显示值,以及一个按钮输入,以启动文件输入单击事件。这适用于FF和IE没有任何问题,但是当我在 Safari 上尝试此操作时,文件输入单击事件不起作用(其他人!!)。

<form action=""  
      name="attachmentPostForm"
      method="post" 
      onSubmit="createAttachmentPostAction(${uid});"
      enctype="multipart/form-data" 
      target="attachementupload_target">
  <input type=file 
         name="leadimagefile" 
         accept="image/gif,image/jpeg" 
         onChange="document.getElementById('ImageFakeFile').value = this.value" 
         id=imageTrueFile style="display:none">
  <input type=text id=ImageFakeFile  readonly>
  <input type = button value="browse" onClick="document.getElementById('imageTrueFile').click()">
  <input type="submit" value="upload" />
</form> 

有没有其他方法可以达到效果,或者在这种情况下我必须使用"正常"文件输入?

不起作用,因为您的输入具有 style="display:none",将其更改为可见性:隐藏,它将起作用。我还建议检查 https://stackoverflow.com/a/3030174/967358