【问题标题】:How do I use to drag an image(image url only) into the droppable area to upload to the server using jquery or ajax?如何使用 jquery 或 ajax 将图像(仅限图像 url)拖到可放置区域以上传到服务器?
【发布时间】:2011-10-02 17:42:39
【问题描述】:

我想通过图像 url 将图像上传到服务器。 将此图像拖放到可放置区域。 (或者有没有办法在 javascript 函数中将图像 URL 发布到另一个页面?)

如何在可放置区域使用 jquery 或 ajax 上传到服务器。

就像一旦我删除了图像,它就会使用图像 url 自动上传到服务器(例如 http://dfghg.com/sss.jpg)。

图片(例如http://dfghg.com/sss.jpg)与放置区域在同一页面内。

这是我的代码

$("#query_image_container").droppable({
        accept: ".thumb",
        activeClass: "ui-state-highlight",
        drop: function( event, ui ) {
            $(this).find(".thumb").remove();

                        $(this).append('<img class="thumb"  src="'+ui.draggable.attr('src')+'">');
            var imageurl = ui.draggable.attr('src');
                $.ajax({
                    type: 'POST',
                    url: 'uploadurl.php',
                    data: imageurl,
                    success:function()
                        {
                        }
                    datatype: 'html'
                });
        }

    });

我可以使用 $.ajax({...});在 droppable 内?

或者有没有其他方法我可以使用“数据:imageurl”对uploadurl.php进行POST?

这个想法是将图像(同一网页上的图像)拖到放置区域,它会自动上传到服务器。

【问题讨论】:

  • 这里真的需要一些帮助。上面的代码是否正确?在 drop 函数中使用 $.ajax

标签: jquery ajax post droppable


【解决方案1】:

你可能不会深入挖掘fileuploadarea,这似乎是你想要的。

【讨论】:

  • fileuploadarea 不允许我通过图像 url 上传它只接受来自文件资源管理器的文件
猜你喜欢
  • 1970-01-01
  • 2012-12-25
  • 2013-06-27
  • 1970-01-01
  • 2022-01-19
  • 2021-11-05
  • 2020-06-28
  • 1970-01-01
  • 2021-12-07
相关资源
最近更新 更多