DropzoneJS:如何在上传成功后获得PHP响应? [英] DropzoneJS: How to get PHP response after upload success?

查看:86
本文介绍了DropzoneJS:如何在上传成功后获得PHP响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的网站上实施Dropzone。我想听取成功事件,然后接受服务器响应,并在上传完成后将一些信息添加到与DropZone相同页面上的表单。

I'm trying to implement Dropzone on my site. I want to listen for the "success" event and then take the server response and add some info from it to a form on the same page as the DropZone after the upload is completed.

我想在服务器响应中获取的信息是该文件的直接链接。

the info i want to get in the server response is a direct link to the file.

dropzone的网站:http://www.dropzonejs.com/

the website of dropzone: http://www.dropzonejs.com/

我的项目网站:

http://37.34.62.131/test/

所以我在我的项目的旧版本中完成了这个,但我无法弄清楚如何使用dropzone.js

so i completed this in a older version of my project but i cant figure it out how to do it with dropzone.js

工作示例:

http://37.34.62.131/test/uploader%201.0/

我尝试做的是当文件上传时我希望将php响应放回到同一页面上,下载链接如下所示。

what i try to do is when a file has been uploaded i want to get the php response back on the same page with the download links as shown below.

我也可以向您发送我的源代码,以便您自己查找。

我希望在回复中看到我的PHP代码:

my php code i want to see in the response:

        print '<h2>Picture Uploaded Successfuly!!!!</h2> <p id="codes">

      <img src="'.$imgurl.'" height="300" alt="Uploaded Picture" >
        <label for="codebb">BBCode:</label>
        <input type="text" id="codebb" value="[URL='.$siteurl.'][IMG]'.$dlurl.'[/IMG][/URL]" onclick="javascript:this.focus();this.select();" readonly="true" /><br />
        <label for="codehtml">HTML Code: </label>
        <input type="text" id="codehtml" value=\'&lt;a href="'.$siteurl.'"&gt;&lt;img src="'.$dlurl.'" alt="'.$alt.'" /&gt;&lt/a&gt;\' onclick="javascript:this.focus();this.select();" readonly="true" /><br />
        <label for="codedirect">Direct Link:</label>
        <input type="text" id="codedirect" value="'.$dlurl.'" onclick="javascript:this.focus();this.select();" readonly="true" /></p>';
        echo ".$newname";

任何人都可以帮我理解我所缺少的东西吗?

Can anyone help me understand what I'm missing?

推荐答案

查看您的网站,您似乎能够解决问题。

Looking at your website, seems like you were able to fix the problem.

无论如何,这适用于可能仍在寻找的人。您需要使用两个参数添加函数成功。返回的第一个参数始终是文件,第二个参数是响应。示例:

Anyways this is for someone who might still be looking. You need to add the function success with two parameters. The first param returned is always file, second one is the response. Sample:

$(function() {
        Dropzone.options.uiDZResume = {
            success: function(file, response){
                alert(response);
            }
        };
    });

这篇关于DropzoneJS:如何在上传成功后获得PHP响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆