views:

40

answers:

1

I'm writing a web app that at one point allows a user to upload a photo to a flickr account (mine). I want to do this without saving the intermediate image on the server my web app is on.

What I've got so far is a page which implements phpFlickr and accepts a POST from a simple html form. I use $_FILES['file']['tmp_name'] as the path for phpFlickr to use. Here's the code:

<?php

require_once("phpFlickr.php");
$f = new phpFlickr("apikey", "secret", true);

$_SESSION['phpFlickr_auth_redirect'] = "post_upload.php";

$myPerms = $f->auth("write");

$token = $f->auth_checkToken();

$phid = $f->sync_upload($_FILES['file']['tmp_name']);

echo "Uploading Photo..." . $phid;

?>

I'm guessing that the tmp file is being lost because of the redirect that happens when $f->auth("write") is called, but I don't know. Is there a way to preserve it? Is there any way to do this without saving the file to the server?

A: 

Answer: There is No way to directly upload a file to Flickr without saving it as an intermediate file.

I've moved on to using move_uploaded_file() followed by a flickr API call, and its working perfectly.

I've also managed to get it to play nice with the excellent Jquery Uploadify, which lets me send multiple files to it in one go.

roryok