Skip to content

@fzaninotto /gist:91d5d368fcf73faebdfe secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
$filenames = scandir($path);
foreach ($filenames as $filename) {
// get the image content
$image = file_get_contents($path . '/' . $filename);
// open an HTTP request to Flickr
$fp = fsockopen('api.flickr.com', 80, $errno, $errstr, 30);
// send the request headers
$out = "POST /services/upload/ HTTP/1.1\r\n";
$out .= "Host: api.flickr.com\r\n";
$out .= "Content-Disposition: attachment; filename=' . $filename' . \r\n";
$out .= "Content-Type: application/octet-stream\r\n";
$out .= "Content-Length: " . strlen($image) . "\r\n\r\n";
fwrite($fp, $out);
// send the image content in the body
fwrite($fp, $image);
fclose($fp);
echo "Sent file " . $filename . "\n";
}
echo "Finished!\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.