- Provided as part of the course materialsis the sample project that we'll useto add photo uploading to.This project is available to runusing the PHP local web server,which we'll start by navigating tothe directory our project is living in,and start it using Lib/Cake/Consul/cake serverand assign a port number.In this case we'll use port 8080.So if we navigate to local host 8080 in our web browser,we should see the standard CakePHP homepage.

So what does this project include?Let's look at the code first.We want to look at the model folder first.It's a standard baked application with three models.User, product, and sale.Let's look at the User Model.Users have an id, a user name, and an email address,and a relationship to sales.On to the next model, Product.Products have an id, an name, a description,and again, with a relationship to sales.

Our final model is the Sale Model.The Sale Model has an id, a user id, and a product id.The Sale Model is basically a join tablebetween products and users,so when we record sales of a product to a user.Ok, now that we understandthe basic model layer of our application,let's walk through the visual side of our application.We want to navigate again to local host 8080,and go to the users directory.We have a standard index page,listing the users we already have in our data base.

Let's add a new user.Click on the New User button.Let's name our new user Bob,and an email address of bob@localhost.com,and click Submit.Now we see we have our new user in our table of users.Now that we've covered users,let's look at products.And again, we have a standard index pagewith products, with names, and descriptions.So let's again add a new product.

Click on the New Product button.Let's add our new product as shirt.With a simple description and submit this.Ok, we now have a Bob user who isgoing to have a purchase of our shirt.Let's go to our sales listing.Notice we list the product name that was purchased,and the user that purchased the product.If we click the add sale button,we can add a new sale to our Bob userfor the shirt product.

We submit this,and we'll see we saved a sale for the product shirt,and to our user Bob.That's the basic functionality of our current application.This is what we'll modify so we can upload and store photosfor both our users and products.the next section will cover adding a new fieldto our users table for our photos.

Resume Transcript Auto-Scroll

Author

Released

7/14/2015

CakePHP is a registered trademark of Cake Software Foundation, Inc.. Cake Software Foundation, Inc. is not affiliated with Lynda.com, nor does it endorse, sponsor, or otherwise support Lynda.com services.

Need to add images to your PHP application? If you've already developed your app with CakePHP, the popular PHP framework, you can easily extend the framework to upload, save, and view photos. Justin Yost shows how to use CakePHP to upload individual photos to a website and add support for uploading multiple photos at one time.