【发布时间】:2012-08-13 00:01:36
【问题描述】:
我正在努力完成的事情
[x] 1) 用户填写表单
[x] 2) 用户通过“拖放 (html5)”或“单击选择图像”将图像添加到表单中 并在页面上显示预览。 (完毕) 在这里很容易添加代码来触发将这些图像上传到服务器,但我现在还不想要。
[x] 3) 用户点击“添加我和我的办公桌” --> 如果用户帐户不存在,则创建用户帐户
[x] 4) 添加了办公桌,并添加了与正确用户的连接。
[x] 5) 使用same name (id) as the desk_id. 创建一个folder
::::THE QUESTION::::
6) -->> now我要upload那些拖拽的,或者选中的图片to that folder。
:::::::::::::::::::
我在这里找到的信息已经走到了这一步:http://www.html5rocks.com/en/tutorials/file/dndfiles/(实际页面真的很震撼!9
我知道这个很棒的解决方案:http://blueimp.github.com/jQuery-File-Upload/ 但这对于我正在尝试做的事情来说太过分了,而且我碰巧很自豪我已经完成了其他所有工作,而且我真的认为我已经很接近了。
不断出现的单词和表达式:读取 blob、检查数组 blob、从沙箱读取、canvas.toDataURL()
感觉答案就在这里:http://www.html5rocks.com/en/tutorials/file/xhr2/ 和/或这里http://www.html5rocks.com/en/tutorials/file/dndfiles/或这里/ http://www.html5rocks.com/en/tutorials/file/filesystem/(在“复制用户选择的文件”下),或在这里http://robertnyman.com/2010/12/16/utilizing-the-html5-file-api-to-choose-upload-preview-and-see-progress-for-multiple-files/
你可以说我在这之后的下一步:Preview an image before it is uploaded 但也许我可以朝着正确的方向前进? :)
我当然看过这些: HTML5 Pre-resize images before uploading facebook js api - HTML5 canvas upload as a photo
当前显示来自 DND 文件的预览,如下所示:
for (var i = 0, f; f = uppladdadeFiler[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
// Render thumbnail.
var span = document.createElement('span');
span.innerHTML = ['<img class="thumb preview" src="', e.target.result,
'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById('listImages').insertBefore(span, null);
var span2 = document.createElement('span');
span2.innerHTML = ['<img class="thumb inside" src="', e.target.result,
'" title="', escape(theFile.name), '"/>'].join('');
document.getElementById('huvudbilden').insertBefore(span2, null);
};
})(f);
$('#valdaBilder').show();
// Read in the image file as a data URL.
reader.readAsDataURL(f);
}
【问题讨论】:
-
毕竟...问题是什么?
-
抱歉输入太长,我把问题标记出来了 (:::QUESTION ::::)
-
我认为您应该在第一次触摸时上传图像(例如,当它们被用户选择时),当过程完成时,将这些图像移动到指定文件夹。这并不复杂。
-
查看用户与之交互的方式,您可能应该有一个清理过程以在一段时间后删除未使用的目录/文件夹。你知道它是怎么回事。
标签: php html image-uploading image-upload