我一直在尝试以动态加载的格式实现一些文件上传器包(原始 php),页面上的数量可能未知。我几乎看过所有流行的,从基于闪存的到介于两者之间的所有东西,但有同样的问题。
我目前正在尝试使用这个。
我已经尝试过我读过的技巧,比如使用^=
ingetelementbyid
以及"\\S*"
确保 javascript 使用相关的 div id,但我没有成功。我还尝试为每个 div 添加一个类名并使用 getelementbyclass 没有成功。我已经到处寻找解决方案,但我就是不明白。
要么我做错了,要么我完全迷失了......我实际上都是!
如果有人能让我摆脱痛苦或让我朝着正确的方向前进,我将非常感激,因为我一直在努力寻找解决方案。
HTML 部分如下所示:
<p id="upload" class="hidden"><label>Drag & drop not supported, but you can still upload via this input field:<br><input type="file"></label></p>
<p id="filereader">File API & FileReader API not supported</p>
<p id="formdata">XHR2's FormData is not supported</p>
<p id="progress">XHR2's upload progress isn't supported</p>
<p>Upload progress: <progress id="uploadprogress" min="0" max="100" value="0">0</progress></p>
<p>Drag an image from your desktop on to the drop zone above to see the browser both render the preview, but also upload automatically to this server.</p>
我打算通过 PHP 动态生成它,其中 $inc 是循环中的 php 变量,例如 id="filereader$inc
我相信这个问题是javascript只会处理上传者的预定义或一个实例,直到以其他方式修改
例如:文件阅读器:document.getElementById('filereader')