NYCPHP Meetup

NYPHP.org

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

ali mohammad ali at vpproperty.com
Mon Oct 15 18:36:08 EDT 2007


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. 



More information about the talk mailing list