There are a number of ways to post an image to Twitter, including using a service such as yfrog or TwitPic. However, for this example we are going to post the image to our own server using PHP and return back the URL. You will need a server running PHP with the GDImage for this recipe to work. There are plenty of cheap or free PHP hosting services online if you don't already have a server. Alternatively, if you are proficient in another web language (such as ASP.NET) you can always rewrite the sample code as you see fit.
Create a new file on your server called upload.php
and save it with the following contents:
<?php $target = getcwd(); $target = $target .'/'. $_POST['randomFilename']; if(move_uploaded_file($_FILES['media']['tmp_name'], $target)) { $filename = $target; // Get dimensions of the original image list($current_width, $current_height...