Blog // Posts tagged with php

 

20 Feb 2009 
5 comments

 
 

Wordpress plugin for Amazon S3

I've created a very simple Wordpress plugin for Amazon S3 which uses my Amazon S3 PHP class.

Currently it allows you to upload files to an S3 bucket and insert them into your post when adding media.

Please note that PHP 5 and the CURL extension are required.

Download the latest version of the plugin.

To install place s3uploader.php into your wp-content/plugins/ directory. After activating the plugin you will need to configure your AWS credentials under Settings - Amazon S3 and select the bucket you would like to upload to.

Planned features for upcoming releases
  • Image resizing
  • Bucket browsing functionality under the media library
Changelog
  • 0.2 (2009-03-07):
    Some improvements and support for file downloads and flash movies
  • 0.1 (2009-02-16):
    Initial release

16 Feb 2009 
2 comments

 
 

Simple PHP upload progress meter using Prototype

The uploadprogress extension is fairly simple to use - but it is important to note that on some PHP configurations it doesn't function correctly and only returns a progress of 100%.

Upload progress screenshot

The JavaScript uses David Stone's method for displaying percentage bars but you can modify the onCreate, onUpdate and onComplete callbacks if you want to use your own.

1) You will need uploadprogress >= 0.3.1 (0.3.0 does not seem to work for me), to build it from source (don't forget to restart your webserver after installing):

                      cvs -d :pserver:cvsread@cvs.php.net:/repository checkout pecl/uploadprogress
cd pecl/uploadprogress && phpize && ./configure && make && sudo make install

2) Progress tracking is automatically enabled if you have a field named UPLOAD_IDENTIFIER with a unique ID in your file upload form:

                      <input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $uploadID; ?>" id="uploadIdentifier" />
                    

3) You retrieve the upload progress with your UPLOAD_IDENTIFIER (obviously these calls will be AJAX requests):

                      $data = uploadprogress_get_info($uploadID);
                    

Once the upload is complete the extension will remove the temporary file and further info calls will return null.

That's it!

See the demo
Download the code

6 Jul 2008 
8 comments

 
 

Imagick

The PHP Imagick documentation is still very much incomplete - but if you're looking for some info on using Imagick with PHP I'd highly recommend checking out Mikko Koppanen's blog for some neat examples.

12 Mar 2008 
No comments

 
 

Amazon S3 PHP Class

This class is a standalone Amazon S3 REST implementation for PHP 5.2.x (using CURL), that supports large file uploads and doesn't require PEAR.

Download source:

Example usage (also see example.php and the class documentation):

                      $s3 = new S3('accessKey', 'secretKey');
$s3->putBucket('bucket', S3::ACL_PUBLIC_READ);
$s3->putObjectFile('file.doc', 'bucket', 'docs/file.doc', S3::ACL_PUBLIC_READ);
$s3->deleteObject('bucket', 'docs/file.doc');

Writing and reading resources:

                      # Upload an object from a resource (requires bytesize):
$s3->putObject($s3->inputResource(fopen($file, 'rb'), filesize($file)), $bucketName, $uploadName, S3::ACL_PUBLIC_READ);
# Download an object to a resource:
$s3->getObject($bucketName, $uploadName, fopen($savefile, 'wb'));

Known Issues:

  • Files larger than 2GB are not supported on 32 bit systems due to PHP's signed integer problem
  • SSL is enabled by default and can cause problems with large files. If you don't need SSL, disable it with S3::$useSSL = false;

More Information:

Changelog

  • 0.4.0 (2009-07-20):
    Updates to copyObject, new getHttpUploadPostParams method for form uploads and fixes for 0 byte PUTs
  • 0.3.8 (2008-12-16):
    Support for spaces and special characters in URIs
  • 0.3.7 (2008-11-27):
    Support for CloudFront and changes to setBucketLogging()
  • 0.3.6 (2008-10-23):
    PHPDoc comment updates
  • 0.3.5 (2008-10-08):
    Added getAuthenticatedURL() and an ACL parameter to copyObject()
  • 0.3.4 (2008-09-11):
    Small updates and support for 0 byte data
  • 0.3.3 (2008-07-30):
    Fixed minor getBucket() bugs, added delimiter
  • 0.3.2 (2008-07-12):
    Fixed ?logging bug and changed putObject() to accept request headers (thanks to Angelo Mandato for providing details)
  • 0.3.1 (2008-06-20):
    Added copyObject() and updated README.txt
  • 0.2.9 (2008-06-20):
    Added getBucketLocation() and a location parameter to putBucket() for EU buckets
  • 0.2.8 (2008-06-06):
    Added sort() for AMZ meta headers (thanks Malone)
  • 0.2.7 (2008-05-30):
    Commented out uncommented var_dump() (thanks Chris)
  • 0.2.6 (2008-05-29):
    Replaced isset() with array_key_exists() since isset() was ignoring null parameters (thanks Joe)
  • 0.2.5 (2008-05-29):
    Added support for ?location and ?torrent parameters (thanks Joe)
  • 0.2.4 (2008-05-27):
    Fix for ?prefix bug (thanks Lucas)
  • 0.2.3 (2008-05-04):
    Small bug fixes, updated examples and comments, moved source to SVN
  • 0.2.2 (2008-05-02):
    Added S3 wrapper example
  • 0.2.1 (2008-04-28):
    First 0.2 beta (0.1 development discontinued)

Amazon S3™ is a trademark of Amazon.com, Inc. or its affiliates.

22 Oct 2007 
258 comments

 

Latest tweets

Hmm. http://yfrog.com/nc1lgj # 24th July 2010

Code obfuscation is cheesy. # 3rd June 2010

@easydns congrats! it's about time :) # 11th May 2010

Home | Blog | About | Contact | Copyright © Donovan Schönknecht Top