需要GD Library Imagecreate才能显示在同一页面上 [英] Need GD Library Imagecreate to display on same page

查看:57
本文介绍了需要GD Library Imagecreate才能显示在同一页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看此处的示例


最终,我希望创建的图像显示在同一浏览器窗口中的更新按钮旁边,而不是加载到新窗口中。然后,每次我输入文本并单击更新时,图像都会重新生成。好像你用用户输入的任何文本自定义图像。


我在网上发现的类似例子是这里。


我只是将文本输入变量发布到PHP文件中以生成以下PHP文件中的图像:

展开 | 选择 | Wrap | 行号

解决方案

< blockquote>您应该考虑使用 Ajax 或者您可以使用显示部分嵌入在 iFrame 中。无论如何,您必须使用JavaScript与服务器进行交互,然后执行 DOM 操作以显示返回的结果。如果你使用更简单的iFrame路线,你只需告诉iframe加载自己的服务器上的正确url和params。


感谢您的快速响应。如何修改PHP输出文件以定位iframe?


嗯?您将要添加JavaScript以与iframe通信。但我发现简单地改变DOM更容易。这个图像是在image.php中创建的吗?然后,您可以允许image.php将字符串作为查询字符串变量。然后,你可以改变src。 < img>的属性元素。


基本上,你会使用JavaScript访问< img>元素和< input>元素和,当按下更新按钮时,然后改变src。 < img>的属性元素类似于http://website.tld/image.php?name = ***在哪里你会替换***使用< input>的值元件。

See example here

Ultimately I want the image created to display next to the update button in the same browser window instead of loading into a new window. Then every time I input text and click ''update'' the image is regenerated. As if you''re customizing the image with whatever text the user inputs.

A similar example I''ve found online is here.

I''m simply just posting the text input variable to a PHP file to generate the image in the following PHP file:

Expand|Select|Wrap|Line Numbers

解决方案

You should look into using Ajax or you could have the display portion embedded in an iFrame. Regardless, you''ll have to use JavaScript to do the interactions with the server and then perform DOM manipulations to display the returned results. If you go the simpler iFrame route, you''d only have to tell the iframe to load itself with the correct url and params on your server.


Thanks for the prompt response. How can I modify the PHP output file to target an iframe?


Hmm? You''ll want to add JavaScript to communicate with the iframe. I find that it''s easier to simply alter the DOM, though. Is this image created in image.php? Then, you could allow image.php to take a string as a query string variable. Then, you could just alter the "src" attribute of an <img> element.

Basically, you''d use JavaScript to access the <img> element and the <input> element and, when the update button is pressed for, then change the "src" attribute of the <img> element to something like "http://website.tld/image.php?name=***" where you''d replace "***" with the value of the <input> element.


这篇关于需要GD Library Imagecreate才能显示在同一页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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