3 require_once('Photo.php');
5 function wall_upload_post(&$a) {
8 echo ( t('Permission denied.') . EOL );
12 if(! x($_FILES,'userfile'))
15 $src = $_FILES['userfile']['tmp_name'];
16 $filename = basename($_FILES['userfile']['name']);
17 $filesize = intval($_FILES['userfile']['size']);
19 $imagedata = @file_get_contents($src);
20 $ph = new Photo($imagedata);
22 if(! $ph->is_valid()) {
23 echo ( t('Unable to process image.') . EOL);
30 $width = $ph->getWidth();
31 $height = $ph->getHeight();
33 $hash = photo_new_resource();
37 $r = $ph->store(local_user(), 0, $hash, $filename, t('Wall Photos'), 0 );
40 echo ( t('Image upload failed.') . EOL);
44 if($width > 640 || $height > 640) {
46 $r = $ph->store(local_user(), 0, $hash, $filename, t('Wall Photos'), 1 );
51 if($width > 320 || $height > 320) {
53 $r = $ph->store(local_user(), 0, $hash, $filename, t('Wall Photos'), 2 );
58 $basename = basename($filename);
59 echo "<br /><br /><img src=\"".$a->get_baseurl(). "/photo/{$hash}-{$smallest}.jpg\" alt=\"$basename\" /><br /><br />";