Picnik Forums
   Home   Help Search Login Register Picnik.com  
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Pages: [1]
Print
Author Topic: Can't export : Probleme whith !isset($_FILES['file'])  (Read 16327 times)
robinb
posted: January 05, 2008, 01:00:45 AM

Hello,

First, thanks for this excellent service Picnik !

I have a probleme, I can't export images with the _export parameter (I use the script of the tutorial, part "Handling a Push").

The script is always stoped here :
Code:
if (!isset($_FILES['file']))
{
echo "Sorry, no image data was sent.";
exit();
}

I don't know why we can't receive the image.

The link is :
Code:
<a class="pbox" href="http://www.picnik.com/service/?_exclude=in,out&_apikey=XXXX&_import=http%3A//www.domaine.com/images/myimage.jpg&_close_target=http%3A//www.domaine.com/mypicnikfiles/close.htm&_export_title=Enregistrer mon image&_host_name=Domaine&_export=http%3A//www.domaine.com/export_image.php&_export_agent=browser">Open Picnik In A Box</a>

Have you an idea how resolve the problem ?

Thanks, and happy new year !

PS : sorry for my bad english, I'm french  Wink
bitnik official steve
(bitnik)

Reply #1 posted: January 07, 2008, 10:19:49 AM

Check out my response to this question: http://forums.picnik.com/index.php/topic,106.0.html

If that doesn't solve your problem, let me know and we can dig further.

Steve
robinb
Reply #2 posted: January 08, 2008, 07:03:06 AM

Hi,

Thanks for helping me.

I hunderstand what is the problem, but not how concretly can I do to solve it...

We need to add somethings in addition of the example script : ?

Code:
<?php
// PHP script to receive image data from Picnik via HTTP POST

// Make sure we've been sent an image.  By default, the
// image data goes into the "file" field, but we could
// change that using the _export_field API parameter.
if (!isset($_FILES['file'])) {
echo "Sorry, no image data was sent.";
exit();
}

// retrieve the image's attributes from the $_FILES array
$image_tmp_filename $_FILES['file']['tmp_name'];
$image_filename $_FILES['file']['name'];

// Save the image to disk.  It'll go into the same directory as
// this script.  You'd probably want to put it somewhere else in the
// file system like a "/images" directory, or maybe even into a database.
// Make sure your web server has write access to the destination dir,
// or the call to file_put_contents isn't going to work.
$image_data file_get_contents$image_tmp_filename );

// Note: file_put_contents requires PHP 5. Use fopen/fwrite/fclose for earlier versions.
file_put_contents$image_filename$image_data );

// Display a result to let the user know what happened.  You
// might need to be smarter about how the $image_link variable is
// built, depending on how your web server is set up.
$image_link dirname($_SERVER['PHP_SELF']) . "/" $image_filename;
echo "Your file was saved to $image_filename.<br/>"
echo "You can find it at this URL: <a href='$image_link'>$image_link</a><br/>";
echo "<img src='$image_link'>";
?>
« Last Edit: January 08, 2008, 08:15:18 AM by robinb »
bitnik official steve
(bitnik)

Reply #3 posted: January 08, 2008, 04:38:20 PM

I guess I'm not sure what your question is.  Are you seeing two hits to your script?  Are you able to log the results of the first hit to your server?  Does that first hit contain any data?

You might want to take a look at the "King of the Hill" sample: http://api.picnik.com/samples/KingOfTheHill

It demonstrates the "push" code in a working environment, and might make things easier to understand.

robinb
Reply #4 posted: January 09, 2008, 08:18:23 AM

Hi,

You  can see here :
http://www.wifeo.com/test-piknic/

I have pasted the same script of the king's pages but the export con't work. (if (isset($_FILES['file'])) {).

You can see le source of the page here : http://www.wifeo.com/test-piknic/index.php?source

Is it possible that is an internal configuration of my server which do that ? (version of PHP ?)

Thanks !
bitnik official steve
(bitnik)

Reply #5 posted: January 09, 2008, 11:37:22 AM

Remember that you're going to see two hits to your server; one POST with the image data and one GET with no image data.  What happens on the first hit?  Is there anything set in the $_FILES array?  You should set up some logging to your server so that you can trace what happens when the image data is POST'ed to you.

The sample does require PHP v5 for file_put_contents().  You can replace that with fopen/fwrite/fclose if you don't have that version.
robinb
Reply #6 posted: January 10, 2008, 02:09:04 AM

no, that's the problem, I don't have anything in the $_FILES array.

that's why the "if (isset($_FILES['file']))" can't works.

Is it possible that a parameter of the configuration of my server block the POST if come from an other server ?
bitnik official steve
(bitnik)

Reply #7 posted: January 10, 2008, 10:31:35 AM

It certainly is possible that your server is blocking POST'd data, although that's not very common.  You'll have to investigate that one on your own.

Are you able to receive an image using the "pull" method instead of the "push" method?
robinb
Reply #8 posted: January 10, 2008, 10:52:27 AM

Thanks for helping me.

Yes, I will try the pull method.

Is there an exemple like the "King of the Hill" sample for this method too ?
bitnik official steve
(bitnik)

Reply #9 posted: January 10, 2008, 03:50:57 PM

BetterOrWorser (http://api.picnik.com/samples/BetterOrWorser) use the pull method for receiving files. 
robinb
Reply #10 posted: January 11, 2008, 10:45:53 AM

that's great and it works very well with the pull method !

Thanks for all and long life to picnik !
galleton
Reply #11 posted: August 30, 2009, 10:18:59 PM

Hi,
I know this is a very Old Post but I have exactly the same case. Installing The King of the Hill sample script I get no data in the Files Array, with the Push method. This is what the debug.txt file shows:
FILES: Array
(
)

POST: Array
(
)

GET: Array
(
    [coronation] =>
)

Thank you anda best regards
Pages: [1]
Print
 
Jump to:  

Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media | © 2006-7 Picnik, Inc.