NYCPHP Meetup

NYPHP.org

[nycphp-talk] How to submit POST vars via html image tags

Jon Baer jonbaer at jonbaer.com
Mon Oct 15 18:50:44 EDT 2007


No post data is being sent, It should be ...

curl_setopt($imgurl, CURLOPT_POSTFIELDS, 'datastuff='.$datastuff);

- Jon

On Oct 15, 2007, at 6:36 PM, ali mohammad wrote:

> Hello,
>
> Hopefully, this is not off-topic. I have a couple of html image tags
> such as <img src="/path/to/file.php" /> on a single web page, and each
> such tag points to an image creating php file that sends out image
> headers and image data after receiving certain data parameters through
> POST. I am unable to figure out how to send POST data to a URL path  
> that
> is embedded inside an img tag (...and not even sure if that is indeed
> the right way to do it).
>
> I need to use POST since there is a limitation on the length of the  
> GET
> vars. I tried using curl (never used it before and just learnt  
> about it)
> to replace the entire img tag...something like this:
>
> $imgurl = curl_init();
> curl_setopt($imgurl, CURLOPT_URL, '/path/to/file.php');
> curl_setopt($imgurl, CURLOPT_POST, 1);
> curl_setopt($imgurl, CURLOPT_POST,'datastuff='.$datastuff);
> curl_exec($imgurl);
> curl_close($imgurl);
>
> Nothing much happens if I do that. I know I can avoid this approach by
> simply using session variables but I am curious if there is an
> alternative approach to this. Any help is much appreciated.
>
> Thanks in advance,
>
> Best Regards,
> Nefertitian.
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list