Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Commenting, Upvoting and Uploading Photos with the 500px API
Mar 10, 2015 @ 11:55:46

The SitePoint PHP blog continues their series creating a simple application based on the 500px service with part two, commenting, upvoting and uploading photos. The 500px service is a photo community for discovering, sharing, buying and selling inspiring photography powered by creative people worldwide.

In the first part of this series we used the API to get the latest photos from 500px and filter through them, and we built a user profile with the list of associated photos. In this part, we are going to give the user the ability to vote, favorite and comment on photos, and finally, we will give the users the ability to upload their own photos.

They start with a look at authentication and authorization handling to make the OAuth-based request to the 500px API. Code is included for the connecting class, including the addition of a logger to make debugging the requests simpler. From there they set up the routes for handling votes on photos (PHP and Javascript) and marking favorite photos. They also include the functionality for adding comments, getting the latest comments and uploading new photos to the service. The final resulting code can be found over on GitHub.

tagged: 500px tutorial api series part2 comment upvote upload photos

Link: http://www.sitepoint.com/commenting-upvoting-uploading-photos-500px-api/

SitePoint PHP Blog:
Adding Products to Your eBay Store with the Trading API
Jan 13, 2015 @ 12:50:14

The SitePoint blog has posted the next part of their "using the eBay trading API" series today (part three) showing you how to add products to your store via their API.

In this third and final part of our eBay Trading API series, we’ll be building the product adding functionality into our application. Now that we’re done with the store settings, we can begin with writing the code for the controller that would handle the creation of products.

He walks you through the code to create the "new" action on your Slim controller, build the view to gather the product information and handle the upload of product images with the Dropzone Javascript library. Also included is the code to get the current category list (to populate a dropdown list) and the code needed to create the product, both in your database and sending it back to the eBay API for insertion. This finishes the series about using this API, but you can get more information on the API itself though its documentation. The full code for the tutorial series is available on GitHub.

tagged: ebay trading api tutorial series part3 add product upload

Link: http://www.sitepoint.com/adding-products-ebay-store-trading-api/

Master Zend Framework:
Create a Simple File Upload Form in Zend Framework 2
Jun 04, 2014 @ 11:51:06

On his "Master Zend Framework" site today Matthew Setter has a new tutorial showing you how to create a simple file upload through the forms handling in Zend Framework 2. The form will include three parts: an input filter, a form class and a controller action to request to show the resulting form.

Having trouble getting file uploads integrated into your forms in Zend Framework 2? Or are you just curious about how to do it, and you want a quick rundown? If either of these is you, come walk through today’s post with me as I show you a simple example of how it’s done – along with how to combine it with filters and validators. Before we get started, I could have composed the code in a much shorter form than have I’ve composed it. But my assumption is that you’re likely using the full-stack framework.

He includes summaries describing each of the three parts of the setup and the code you'll need to create each. The validator checks for things like "too big", "too small" and the correct MIME type on the file given. The form itself only includes the file upload element with a description of "Attachment". The controller action creates the form instance and calls an "isValid" when the upload happens to execute the validation. He also throws in the view template to display the form itself.

tagged: zendframework2 simple file upload tutorial form

Link: http://www.masterzendframework.com/forms-2/simple-file-upload-form

Christian Weiske:
PHP 5.6: Large file upload support
Dec 11, 2013 @ 11:09:47

Christian Weiske has posted information about a feature in the upcoming PHP 5.6 version of the language - large file upload support. This new feature allows files over 4GB to be uploaded correctly.

PHP version 5.6 brings support for file uploads larger than 2GiB. We can say "thank you" to Ralf Lang for the initial patch that fixes bug #44522 , which was open since 2008. During testing uploads of files with a size of 4 - 11GiB on my PHP-CGI setup, I noticed that files above 4GiB did not get uploaded correctly. Michael Wallner was quick to fix that bug, and now 5.6 has fully working support for big files.

PHP 5.6 is still in development and some other new features are slated to be added to it. You can find some of them listed in the RFC section of the PHP wiki.

tagged: php56 large file upload bug patch

Link: http://cweiske.de/tagebuch/php-large-file-uploads.htm

Phil Sturgeon:
CurlFile and the Facebook SDK in PHP 5.5
Aug 30, 2013 @ 11:19:04

Phil Sturgeon has a new post to his site today looking at a new feature that's included with PHP 5.5, Curlfile, and how he uses it with calls to the Facebook API (and a fix to make it cooperate).

One of the features implemented in PHP 5.5 was CurlFile, a nice addition to the Curl extension to allow you to specify specific arguments as a file for upload. In previous versions (pre-PHP 5.5) the syntax looked like this: [@/foo/bar.jpg]. A little digging around lead me to try this syntax: [new CURLFile('/foo/bar.jpg','image/jpeg')]. Sadly while Curl was happy with this, the Facebook PHP SDK (v3.2.2) was not. It turns out the SDK will turn ANY value you send it in that params array into a string.

To get around the issue, he worked up his own fix to the Facebook PHP SDK and submitted a patch to get it introduced into the tool. He also includes a reminder to filter incoming user data for things containing the "@" too to prevent unwanted file transfers.

tagged: curlfile curl file upload facebook sdk patch json

Link: http://philsturgeon.co.uk/blog/2013/08/curlfile-and-the-facebook-sdk-in-php-55

How to Build a Dynamic Imgur Upload App Using jQuery & PHP
Aug 30, 2013 @ 09:51:03

On DesignShack.com Jake Rocheleau has a tutorial showing you how to create an image uploader that pushes the image over to the Imgr service.

In this tutorial I want to demonstrate how we can remotely mirror an image found elsewhere online and auto-upload to Imgur. It’s possible to create a form handling user-uploaded images as well. But I wanted to keep the demo clean without needing to move user content onto the server. This process is very simple once you understand how APIs work.

He provides all of the code and guidance you'll need to get the system working. It uses a simple HTML layout, some jQuery for submitting the image data back to the the server and a PHP script to call the Imgr API. It uses curl to make the call, so you'll need that extension installed to use the example. You can check out the live demo or just download the source to get started quickly.

tagged: imgr upload jquery tutorial javascript api curl

Link: http://designshack.net/articles/javascript/how-to-build-a-dynamic-imgur-upload-app-using-jquery-php/

Amazon Web Services PHP Blog:
Syncing Data with Amazon S3
Jun 28, 2013 @ 11:57:59

On the Amazon AWS blog there's a recent post showing you how to sync data with S3 and handle multiple files quickly and easily.

Have you ever needed to upload an entire directory of files to Amazon S3 or download an Amazon S3 bucket to a local directory? With a recent release of the AWS SDK for PHP, this is now not only possible, but really simple.

He includes example code for doing it both ways - upload and download syncing - as well as some options you can use to customize the connection. You can define things like ACL settings, the number of concurrent connections and if you want the debug options turned off or on.

tagged: sync amazon s3 tutorial upload download

Link: http://blogs.aws.amazon.com/php/post/Tx2W9JAA7RXVOXA/Syncing-Data-with-Amazon-S3

Phil Sturgeon:
Package Watch: Image Management
Sep 19, 2012 @ 12:32:14

Phil Sturgeon has a new post to his site talking about how he added image upload and management support to an application with an easy integration of two packages (pulled in via Composer).

To get this extra functionality I added two packages to my composer.json. [...] The first is Upload by Josh Lockhart (who built Slim and started PHP The Right Way). It's currently very basic as it's not been alive long, but for the job I needed to do it worked perfect.

The second package is the ImageWorkshop that let him easily resize the uploaded images and add a watermark to the corner. He also points out that this method of pulling together packages, each with their own specializations, is the "early days of a PHP renaissance" in how people will work with the language.

tagged: image management composer package upload imageworkshop tutorial


Vimeo API - OAuth and Upload Example
Jul 16, 2012 @ 12:03:11

On the Script-Tutorials.com site there's a new tutorial showing how to use the Vimeo API to upload your content to their service:

Today I would like to continue talking about video. Last time we talked about Youtube, but today I decided to select Vimeo. [...] Our second example – Vimeo. In our new tutorial I will tell you how you can create Vimeo cross-uploader for your website. To achieve our idea we will use Vimeo Upload API. In the beginning, we should register at Vimeo here.

The full code for the upload script, the HTML for the frontend for it and the CSS to give it a little bit of style. You can see a demo of it here or just download the source.

tagged: vimeo api upload example tutorial oauth


Tracking Upload Progress with PHP and JavaScript
Feb 06, 2012 @ 13:58:32

In a new tutorial today from PHPMaster.com, they show you how to combine Javascript and a PHP feature to track the progress of an upload to your web application.

A problem that has plagued web developers for years is how to add real-time information to their applications, such as a progress bar for file uploads. [...] JavaScript can access a file’s name, type, and even the width and height of a local image, but it wasn’t until HTML5 that it could access a file’s size. [...] In this article I’ll show you how [the session.upload_progress] feature can be used to create a simple upload progress bar without any external libraries or browser dependencies.

The tutorial provides all the steps you'll need to get it working - defining the form with the extra required field, styling it and plugging the Javascript in to call a small script to get the progress of the upload. It returns the difference between the content-length of the file and the current size (as a percentage of 100).

tagged: track upload progress extension javascript tutorial progressbar