LulzImg.com Upload Example (API)

Try RingCentral Mobile FREE for 30 days

LulzImg has recently (months back) opened up it’s api for developers. So here is the example of how to use it in your applications to upload an image. The coding is in PHP so make a note of it.

Thanks to Lifetalk for the post.

It accepts an image, a zip, or a rar file. If it encounters a zip/rar file, it’ll extract it, and copy any images found in it. It’ll dump everything else inside; dumping happens during run-time so don’t bother trying to inject malicious files/code.

You basically need to make your script simulate this form:

<form enctype="multipart/form-data" action="http://lulzimg.com/app.php" method="POST"> <input type="file" name="image" id="image" /> <br /> <input type="submit" name="submit" value="submit"></button> </form>

PHP Example :

<code><code> <?php

function curl($link, $postfields = '')
{
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
if($postfields)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
}
$page = curl_exec($ch);
curl_close($ch);
return($page);
}

$img = "C:\Program Files\VertrigoServ\www\img.jpg"; //Or linux path
$post = array();
$post['image'] = "@$img";
$post['submit'] = "submit";
$page = curl("http://lulzimg.com/app.php", $post);
echo $page;

?> </code></code>

Return/output is the resulting links, each on a new line. I don’t remember if it’s separated by a “\n” or a “<br />” but you can look up the source code and do a regex match accordingly.

Posts may be interesting

Unlimited US, Canada, Australia, Europe calls! India 2.9 c/min! Just $4.95/mo. Limited time offer.

VPN service that supporting Symbian, Android, iPhone, PC and Mac.

Click here to get your unique SkypeIn number

Leave a Reply


2 + seven =